1. 程式人生 > >在pipeline中寫json檔案

在pipeline中寫json檔案

#write items to json file
import json
class 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