def from_crawler(cls, crawler):
try:
output_path = (
crawler.settings.get('FEEDS_CONFIG')['feeds']['output_path']
)
except (KeyError, TypeError):
output_path = 'output'
try:
output_url = (
crawler.settings.get('FEEDS_CONFIG')['feeds']['output_url']
)
except (KeyError, TypeError):
output_url = None
pipeline = cls(output_path=output_path, output_url=output_url)
crawler.signals.connect(pipeline.spider_opened, signals.spider_opened)
crawler.signals.connect(pipeline.spider_closed, signals.spider_closed)
return pipeline
评论列表
文章目录