How can I use different pipelines for different spiders in a single Scrapy project

CodeMonkeyB picture CodeMonkeyB · Dec 4, 2011 · Viewed 25.1k times · Source

I have a scrapy project which contains multiple spiders. Is there any way I can define which pipelines to use for which spider? Not all the pipelines i have defined are applicable for every spider.

Thanks

Answer

Mirage picture Mirage · Jan 7, 2016

Just remove all pipelines from main settings and use this inside spider.

This will define the pipeline to user per spider

class testSpider(InitSpider):
    name = 'test'
    custom_settings = {
        'ITEM_PIPELINES': {
            'app.MyPipeline': 400
        }
    }