类型错误:process_spider_output() 为关键字参数“响应”获得了多个值

2 python scrapy

我有一个像这样的爬虫中间件类

class SaveSpiderMidlleWare:
    """ This is a middleware class which handles all the operations of  saving the spider response data into flat file """

    def  process_spider_output(response, result, spider):
        print("Response :",response.url)
        return response
Run Code Online (Sandbox Code Playgroud)

哪个返回此错误

TypeError: process_spider_output() got multiple values for keyword argument 'response'
Run Code Online (Sandbox Code Playgroud)

关于触发爬行蜘蛛

Paw*_*ech 5

def  process_spider_output(response, result, spider):
Run Code Online (Sandbox Code Playgroud)

应该

 def process_spider_output(self, response, result, spider):
Run Code Online (Sandbox Code Playgroud)

这个方法是中间件对象的方法,python中的对象方法总是引用对象作为第一个参数。这个方法的文档不包括selfparam 可能假设它的存在是显而易见的。