Scrapy 不启用我的 FilePipeline
Scrapy does not enable my FilePipeline
这是我的 settings.py:
from scrapy.log import INFO
BOT_NAME = 'images'
SPIDER_MODULES = ['images.spiders']
NEWSPIDER_MODULE = 'images.spiders'
LOG_LEVEL = INFO
ITEM_PIPELINES = {
"images.pipelines.WritePipeline": 800
}
DOWNLOAD_DELAY = 0.5
这是我的 pipelines.py:
from scrapy import Request
from scrapy.pipelines.files import FilesPipeline
class WritePipeline(FilesPipeline):
def get_media_requests(self, item, info):
for url in item["file_urls"]:
yield Request(url)
def item_completed(self, results, item, info):
return item
这是非常标准、正常的东西。然而这是我的日志中的一行:
2015-06-25 18:16:41 [scrapy] INFO: Enabled item pipelines:
因此管道未启用。我在这里做错了什么?我现在已经用过几次 Scrapy,我相当肯定蜘蛛没问题。该项目只是 file_urls
和 files
.
的普通项目
我不太了解 FilesPipeline
,但对于每个管道,您都需要实施 process_item(self, item, spider)
方法。
糟糕,我忘记在设置中添加 FILES_STORE
。查看 here 以获得解释。
相关引用:
Then, configure the target storage setting to a valid value that will be used for storing the downloaded images. Otherwise the pipeline will remain disabled, even if you include it in the ITEM_PIPELINES setting.
这是我的 settings.py:
from scrapy.log import INFO
BOT_NAME = 'images'
SPIDER_MODULES = ['images.spiders']
NEWSPIDER_MODULE = 'images.spiders'
LOG_LEVEL = INFO
ITEM_PIPELINES = {
"images.pipelines.WritePipeline": 800
}
DOWNLOAD_DELAY = 0.5
这是我的 pipelines.py:
from scrapy import Request
from scrapy.pipelines.files import FilesPipeline
class WritePipeline(FilesPipeline):
def get_media_requests(self, item, info):
for url in item["file_urls"]:
yield Request(url)
def item_completed(self, results, item, info):
return item
这是非常标准、正常的东西。然而这是我的日志中的一行:
2015-06-25 18:16:41 [scrapy] INFO: Enabled item pipelines:
因此管道未启用。我在这里做错了什么?我现在已经用过几次 Scrapy,我相当肯定蜘蛛没问题。该项目只是 file_urls
和 files
.
我不太了解 FilesPipeline
,但对于每个管道,您都需要实施 process_item(self, item, spider)
方法。
糟糕,我忘记在设置中添加 FILES_STORE
。查看 here 以获得解释。
相关引用:
Then, configure the target storage setting to a valid value that will be used for storing the downloaded images. Otherwise the pipeline will remain disabled, even if you include it in the ITEM_PIPELINES setting.