我已经发布了上周,我的机器人总是在321页封锁。我更改了Scrapy设置,但注意到321和结尾之间的页面似乎不包含任何项。你知道吗
我想知道如何跳过产生错误的页面。我试过这个:
next_pages = response.xpath("//div[@class='pgLightPrevNext']/a/@href").extract() #essai pour accéder au contenu des pages suivantes
for next in next_pages:
absolute_url = self.base_url + next
try:
yield scrapy.Request(absolute_url, callback=self.parse_dir_contents)
except:
pass
但没有结果。我怎么能跳过那些页?你知道吗
谢谢。你知道吗
在下一个获取数据的函数中,检查response==200。 如果响应不等于200,则可以在特定限制下使用retry变量,使用另一个函数重试该url。如果超过了限制,请转到下一个产品url。你知道吗
如果为页面收集的项目数为
0
,则可以return
。你知道吗相关问题 更多 >
编程相关推荐