1. 程式人生 > >scrapy 編寫爬蟲遇到NameError: Module 'myspider.pipelines' doesn't define any object named 'SomePipeline'

scrapy 編寫爬蟲遇到NameError: Module 'myspider.pipelines' doesn't define any object named 'SomePipeline'

scrapy 編寫爬蟲遇到NameError: Module ‘myspider.pipelines’ doesn’t define any object named 'SomePipeline’解決方案:

pipeLines.py

class MyspiderPipeline(object):
    def process_item(self, item, spider):
        return item

settings.py

# Configure item pipelines
# See http://scrapy.readthedocs.org/en/latest/topics/item-pipeline.html
ITEM_PIPELINES = {
   'myspider.pipelines.SomePipeline': 300,
}

以上問題是由於 pipeLines.py 檔案中的類名與 settings.py 檔案中的ITEM_PIPLINES中的 SomePipeline 不一致導致的。將settings.py配置檔案中的SomePipeline改為類名 MyspiderPipeline即可。