If you want different spiders to have different pipelines, you can set the attribute of the list of pipelines for the spider, which defines the pipelines for this spider. Then in the pipelines check for:
class MyPipeline(object):
def process_item(self, item, spider):
if self.__class__.__name__ not in getattr(spider, 'pipelines',[]):
return item
...
return item
class MySpider(CrawlSpider):
pipelines = set([
'MyPipeline',
'MyPipeline3',
])
If you want different elements to be handled by different pipelines, you can do this:
class MyPipeline2(object):
def process_item(self, item, spider):
if isinstance(item, MyItem):
...
return item
return item
source
share