如何将 SitemapSpider 收集的 CSV 文件的链接提供给第二个蜘蛛 CSVFeedSpider

How to feed links to CSV files gathered by SitemapSpider into second spider that is CSVFeedSpider

我有一个站点地图蜘蛛,可以收集到 csv 文件的链接。我想使用 csv 蜘蛛来爬过这些链接。我将如何将一个蜘蛛的输出提供给另一个蜘蛛?

参见 official documentation 中的示例:

from scrapy.spiders import CSVFeedSpider
from myproject.items import TestItem

class MySpider(CSVFeedSpider):
    name = 'example.com'
    allowed_domains = ['example.com']
    start_urls = ['http://www.example.com/feed.csv']
    delimiter = ';'
    quotechar = "'"
    headers = ['id', 'name', 'description']

    def parse_row(self, response, row):
        self.logger.info('Hi, this is a row!: %r', row)

        item = TestItem()
        item['id'] = row['id']
        item['name'] = row['name']
        item['description'] = row['description']
        return item

要将其与本地文件一起使用,只需使用文件 url:file:///home/user/some.csv