I have a Scrapy project with multiple spiders along with multiple pipelines. Is there a way I can tell Spider A to use pipeline A, etc???
My pipelines.py has multiple pipeline classes each doing something different and I want to be able to tell a spider to use a specific pipeline.
I do not see any obvious ways looking at the available scrapy commands to do this...
ITEM_PIPELINES
setting is defined globally for all spiders in the project during the engine start. It cannot be changed per spider on the fly.
Here's what you can do. Define what spiders should be processed via the pipeline in the pipeline itself. Skip/continue processing items returned by spiders in the process_item method of your pipeline, e.g.:
def process_item(self, item, spider):
if spider.name not in ['spider1', 'spider2']:
return item
# process item
Also see:
Hope that helps.
It is possible to specify the pipeline to use in the custom_settings property of your spider class:
class BookSpider(BaseSpider):
name = "book_spider"
custom_settings = {
'ITEM_PIPELINES': {
'my_app.pipelines.BookPipeline': 300,
}
}
def parse(self, response):
return
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With