如何从Spider回调中收集统计信息?
例
class MySpider(Spider): name = "myspider" start_urls = ["http://example.com"] def parse(self, response): stats.set_value('foo', 'bar')
总体上不确定该import如何stats使用或如何使用。
从scrapy文档中查看统计信息页面。该文档指出Stats Collector,但可能需要添加from scrapy.stats import stats到你的Spider代码中才能对其进行处理。
from scrapy.stats import stats
EDIT2:经过大量的谷歌搜索,显然没有必要导入。只需使用self.crawler.stats.set_value()!
self.crawler.stats.set_value()