Scrapy to different Item separate storage

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

Object judgment in Piperlines,

def process_item(self, item, spider):
    if item.__class__ == BaseItem :
        #savexxx
    else item.__class__ == BookItem:
        #savexxx222
    return item 

This object can also be written judgment 

isinstance(item,BaseItem)  #The inherited class will be True, and the __class__ must be a class

type(item)Only the built-in objects can be used.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Gladys at November 13, 2013 - 12:16 PM