ImageSpider icon indicating copy to clipboard operation
ImageSpider copied to clipboard

你的递归爬取问题解决了吗,我这也是递归yield的Request没反应

Open xcf007 opened this issue 7 years ago • 2 comments

你的递归爬取问题解决了吗,我这也是递归yield的Request没反应

xcf007 avatar Mar 08 '17 07:03 xcf007

@xcf007 我也并没有搞懂为什么。我在博客中写了, 下面这样子的代码,是可以正常工作的,就是把item的解析放在parse函数里面

def parse(self, response):
    # doSomething
    for item in items
        yield item
    for url in urls
        yield Request(url, callback=self.parse)

但是如果把对item的解析单独提取成一个函数,就不行了。就是这样子的代码:

def parse_item(self, response):
    # doSomething
    for item in items
        yield item

def parse(self, response):
    # doSomething
    self.parse_item(response)
    for url in urls
        yield Request(url, callback=self.parse)

wly2014 avatar Mar 08 '17 09:03 wly2014

我的找到原因了,是域名过滤造成的。

xcf007 avatar Mar 16 '17 06:03 xcf007