我有一个Spider,它会抓取无法保存在一个项目类中的数据.
为了说明,我有一个配置文件项,每个配置文件项可能有未知数量的注释.这就是我想要实现Profile Item和Comment Item的原因.我知道我可以简单地通过使用yield将它们传递给我的管道.
但是,我不知道具有一个parse_item函数的管道如何处理两个不同的项类?
或者是否可以使用不同的parse_item函数?
或者我必须使用几个管道?
或者是否可以将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)