Return to Snippet

Revision: 59335
at September 1, 2012 07:15 by scrapy


Initial Code
# Small monkey patch for images pipeline to make it works with spider, which crawling Items of different nature (and some of this items doesn't have images)

from scrapy.contrib.pipeline.images import ImagesPipeline

old_item_completed = ImagesPipeline.item_completed

def new_item_completed(self, results, item, info):
    if 'image_urls' in item:
        return old_item_completed(self, results, item, info)
    else:
        return item

        
if ImagesPipeline.item_completed != new_item_completed:
    ImagesPipeline.item_completed = new_item_completed

# Snippet imported from snippets.scrapy.org (which no longer works)
# author: dchaplinsky
# date  : Nov 26, 2010

Initial URL

                                

Initial Description

                                

Initial Title
Monkey patch for images pipeline

Initial Tags
images

Initial Language
Python