这也不算报错哈
解决方法
在process_item
处理完成后返回item即可:
return item
案例分析
比如下面的pipeline
:
class MyPipeline(object):
def __init__(self):
host = "127.0.0.1"
user = "xxx"
password = "xxx"
db = "xxx"
self.conn = pymysql.connect(host=host, user=user, password=password, database=db)
self.cursor = self.conn.cursor()
def process_item(self, item, spider):
if isinstance(item, StockItem):
sql = "INSERT INTO stock_code(code,company,stock_type) VALUES ('%s','%s','%s');" % \
(item["stock_code"], item["company_name"], item["stock_type"])
self.cursor.execute(sql)
self.conn.commit()
return item # 如果去掉这一行,会打印None,返回item即可