存储到mysql、mongodb

存储到mysql、mongodb

1、需要先配置setings.py文件

ITEM_PIPELINES = {
   'csdn.pipelines.CsdnPipeline': 300,
   'csdn.pipelines.MysqlPipeline': 301,

}

2、再在pipelines.py文件中创建

class MysqlPipeline(object):
    def open_spider(self,spider):
        pass
    def process_item(self,item,spider):
        return item
    def close_spider(self,spider):
        pass

你可能感兴趣的:(存储到mysql、mongodb)