博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
pipelines.py
阅读量:5221 次
发布时间:2019-06-14

本文共 597 字,大约阅读时间需要 1 分钟。

# -*- coding: utf-8 -*-# Define your item pipelines here## Don't forget to add your pipeline to the ITEM_PIPELINES setting# See: https://doc.scrapy.org/en/latest/topics/item-pipeline.htmlimport jsonclass ItteachersPipeline(object):    def __init__(self):        self.filename = open("teacher.json","w")    def process_item(self, item, spider):        jsontext = json.dumps(dict(item), ensure_ascii = False) + "\n"        self.filename.write(jsontext.encode("utf-8"))        return item    def close_spider(self, spider):        self.filename.close()

 

转载于:https://www.cnblogs.com/hizf/p/8271497.html

你可能感兴趣的文章