scrapy项目:何时归还?

时间:2013-03-25 02:10:57

标签: parsing return scrapy

问题在于:

  1. 我可以在A网页中找到项目数据,然后按照A的外链接来 获得额外的物品数据。
  2. 附加项目数据位于B和C网页中。有一个parse_b() 对于B,parse_c()表示C(这两个解析是回调 parse_A())。此项目数据完成后。
  3. 那么,parse()返回项目?

1 个答案:

答案 0 :(得分: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"