Scrapy: AttributeError: 'list' object has no attribute 'iteritems'

时间秒杀一切 提交于 2019-12-02 19:10:37

This is caused by the linked-in scraper's settings:

ITEM_PIPELINES = ['linkedIn.pipelines.LinkedinPipeline']

However, ITEM_PIPELINES is supposed to be a dict, according to the doc:

To activate an Item Pipeline component you must add its class to the ITEM_PIPELINES setting, like in the following example:

ITEM_PIPELINES = {
    'myproject.pipelines.PricePipeline': 300,
    'myproject.pipelines.JsonWriterPipeline': 800,
}

The integer values you assign to classes in this setting determine the order in which they run: items go through from lower valued to higher valued classes. It’s customary to define these numbers in the 0-1000 range.

According to this question, it used to be a list, which explains why this scraper uses a list. So you will have to either ask your the developer of the scraper to update their code, or to set ITEM_PIPELINES yourself.

The short answer is the ITEM_PIPELINES should be a dictionary not a list with the key as the pipeline class and value an integer that determines the order in which they run: items go through from lower valued to higher valued classes. It’s customary to define these numbers in the 0-1000 range. as explained by @valentin Lorentz

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!