小编Nin*_*ina的帖子

Scrapy,Python:一个管道中的多个项目类?

我有一个Spider,它会抓取无法保存在一个项目类中的数据.

为了说明,我有一个配置文件项,每个配置文件项可能有未知数量的注释.这就是我想要实现Profile Item和Comment Item的原因.我知道我可以简单地通过使用yield将它们传递给我的管道.

  1. 但是,我不知道具有一个parse_item函数的管道如何处理两个不同的项类?

  2. 或者是否可以使用不同的parse_item函数?

  3. 或者我必须使用几个管道?

  4. 或者是否可以将Iterator写入Scrapy项目字段?


comments_list=[]
comments=response.xpath(somexpath)
for x in comments.extract():
        comments_list.append(x)
    ScrapyItem['comments'] =comments_list
Run Code Online (Sandbox Code Playgroud)

python pipeline scrapy

12
推荐指数
3
解决办法
7429
查看次数

标签 统计

pipeline ×1

python ×1

scrapy ×1