You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
951 B

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://docs.scrapy.org/en/latest/topics/item-pipeline.html
# -*- coding: utf-8 -*-
# useful for handling different item types with a single interface
import requests
from itemadapter import ItemAdapter
# 排列次序
class MyfirstpjPipeline:
def process_item(self, item, spider):
# file = open("items.txt", "a") # 以追加的方式打开文件,不存在则创建
# # 因为item中的数据是unicode编码,为了在控制台中查看数据的有效性和保存,
# # 将其编码改为utf-8
# item_string = str(item).decode("unicode_escape").encode('utf-8')
# file.write(item_string)
# file.write('\n')
# file.close()
# print(item_string) # 在控制台输出
# return item # 会在控制台输出原item数据,可以选择不写
print(item)