-2

这是问题所在:

  1. 我可以在 A 网页中找到 Item 数据,然后按照 A 的外链获取更多 Item 数据。
  2. 附加项目数据在 B 和 C 网页中。有一个parse_b() for B,一个parse_c()for C(这两个解析是parse_A()中的回调)。此项目数据完成后。

那么,在哪个parse()退货项目?

4

1 回答 1

0

看向https://github.com/darkrho/scrapy-inline-requests

看起来像这样:

class FooSpider(BaseSpider):
    @inline_request
    def parse_a(self, response):
        l = FooLoader()
        l.add_value("A", "A")
        b = yield Request(response.url + '/b)
        l.add_value("B", b)
        c = yield Request(response.url + '/c)
        l.add_value("C", c)
        yield l.load_item()

    @inline_request
    def parse_b(self, response):
        # Doing what you want
        return "B"

    @inline_request
    def parse_c(self, response):
        # Doing what you want
        return "C"
于 2013-03-26T14:25:21.400 回答