Precisely catch DNS error with Python requests
问题 I am trying to make a check for expired domain name with python-requests . import requests try: status = requests.head('http://wowsucherror') except requests.ConnectionError as exc: print(exc) This code looks too generic. It produces the following output: HTTPConnectionPool(host='wowsucherror', port=80): Max retries exceeded with url: / (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 11001] getaddrinfo failed',)) What I'd like to do is to catch this DNS error