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資料管道
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/110805.html
標籤:Python
下一篇:Python錯誤與例外
