how to scrapy handle dns lookup failed

落爺英雄遲暮 提交于 2019-12-05 23:27:44

问题


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.


回答1:


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


来源:https://stackoverflow.com/questions/25840049/how-to-scrapy-handle-dns-lookup-failed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!