我有一个管道在我的刮痧,我需要得到一个信息从刮痧统计
class MyPipeline(object):
def __init__(self, stats):
self.stats = stats
@classmethod
def from_crawler(cls, crawler):
return cls(crawler.stats)
def process_item(self, item, spider):
print self.stats.get_stats()['item_scraped_count']
return item
当我运行代码时,我得到了这个错误
^{pr2}$如果这不是获取stats值的正确方法,那么我应该怎么做?在
找到答案了!终于来了!在
使用
self.stats.get_value('item_scraped_count')
代替self.stats.get_stats()['item_scraped_count']
https://doc.scrapy.org/en/latest/topics/stats.html
相关问题 更多 >
编程相关推荐