我们应该在 ItemPipeline 还是在蜘蛛本身中处理抓取的数据?

问题描述

我有一只蜘蛛:

import os
import scrapy
from items import BookItem


class MyBookSpider(scrapy.Spider):
    name = 'my_book_spider'

    custom_settings = {
        'ITEM_PIPELInes': {
            'pipelines.ProcessBookPipeline': 1,}
    }
    
    def start_requests(self):
        yield scrapy.Request(
            "http://mybook.com",callback=self.process_data,)

    def process_data(self,response):
        # Do the process here
        yield item

我应该在 process_data 函数中处理抓取的数据还是生成临时项目并在 ProcessBookPipeline 中继续处理?。因为我的处理流程有点复杂,有点长。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)