无法从Scrapy stats字典获取值

2024-09-28 03:21:30 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个管道在我的刮痧,我需要得到一个信息从刮痧统计

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值的正确方法,那么我应该怎么做?在


Tags: fromself信息return管道objectinitdef

热门问题