在pipeline中写json文件

来源:互联网 发布:数据农场采集器 编辑:程序博客网 时间:2024/06/04 19:51

#write items to json fileimport jsonclass JsonwritePipeline(Object):def process_item(self, item, spider):line = json.dumps(dict(item)) + "\n"with open(filename.json, "wb") as f:f.write(line)return item