from scrapy.exporters import JsonLinesItemExporter class BossPipleline(object): def __init__(self): self.fp=open('jobs.json','wb') self.exporter=JsonLinesItemExporter(self.fp,ensure_ascii=False) def process_item(self,item,spider): self.exporter.export_item(item) return item def close_spider(self,spider): self.fp.close()
#注意:最后要在settings文件里面开起piplines数据管道