Advertisement
Guest User

Untitled

a guest
Apr 6th, 2015
529
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.97 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2.  
  3. # Define your item pipelines here
  4. #
  5. # Don't forget to add your pipeline to the ITEM_PIPELINES setting
  6. # See: http://doc.scrapy.org/en/latest/topics/item-pipeline.html
  7. import sys
  8.  
  9. class BoroughscrperPipeline(object):
  10.     def process_item(self, item, spider):
  11.  
  12.       def check_spider_pipeline(process_item_method):
  13.  
  14.         @functools.wraps(process_item_method)
  15.         def wrapper(self, item, spider):
  16.             # message template for debugging
  17.           msg = '%%s %s pipeline step' % (self.__class__.__name__,)
  18.  
  19.             # if class is in the spider pipeline then use use process_item normally
  20.           if self.__class__ in spider.pipeline:
  21.             spider.log(msg % 'executing', level=log.DEBUG)
  22.             return process_item_method(self, item, spider)
  23.  
  24.             # otherwise return the untouched item
  25.           else:
  26.             spider.log(msg % 'skipping', level=log.DEBUG)
  27.             return item
  28.  
  29.         return wrapper
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement