python爬虫(十八)-------------------scrapy piplines.py

当一个item被蜘蛛爬取到之后会被发送给Item Pipeline,然后多个组件按照顺序处理这个item

 Item Pipeline常用场景 :

清理HTML数据

 验证被抓取的数据(检查item是否包含某些字段) 

重复性检查(然后丢弃)

将抓取的数据存储到数据库中

1 编写items.py

2 在myspider.py中填充items

3 然后才能使用piplines.py

原始pipelines.py:

# -*- 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.html


class FistscrapyPipeline(object):
    def process_item(self, item, spider):
        return item

猜你喜欢

转载自blog.csdn.net/qq_41228218/article/details/88990962