0

Scrapy creates scrapy.http.Request objects for each URL in the start_urls attribute of the Spider, and assigns them the parse method of the spider as their callback function.

https://github.com/scrapy/scrapy/blob/master/scrapy/spider.py

The documents has the description as above. But I cannot find the place where calls parse() as its callback function.

def parse(self, response): raise NotImplementedError

Can someone let me know where calls the function above? Thanks.

4

1 回答 1

0

它在scrapy/core/scraper.py

def call_spider(self, result, request, spider):
    result.request = request
    dfd = defer_result(result)
    dfd.addCallbacks(request.callback or spider.parse, request.errback)
    return dfd.addCallback(iterate_spider_output)
于 2013-05-24T16:26:15.833 回答