如何刮取处理dns查找失败 [英] how to scrapy handle dns lookup failed

查看:215
本文介绍了如何刮取处理dns查找失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



以下是我看到的错误:

 错误:下载< GET http://domain.com>:DNS查找失败:找不到地址'domain.com'[Errno 8] nodename或servname提供,或不知道。 

当我收到这样的错误时,如何通知我,以便我可以自己处理,

解决方案

使用 errback 回调:

 请求(url,callback = your_callback,errback = your_errorback)

errback

  def your_errorback(self,response):
//你的逻辑将在这里


I am looking to handle a DNS error when scraping domains Scrapy.

Here's the error that I am seeing:

ERROR: Error downloading <GET http://domain.com>: DNS lookup failed: address 'domain.com' not found [Errno 8] nodename nor servname provided, or not known.

How could I be notified when I get an error like this, so that I can handle it myself without Scrapy just throwing an error and moving on.

解决方案

Use errback along with callback:

Request(url, callback=your_callback, errback=your_errorback)

and errback:

def your_errorback(self, response):
    //your logic will be here

这篇关于如何刮取处理dns查找失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆