I'm trying to validate some urls that are passed to me. I want to make sure that they resolve to an existing website. In the process, I've coded:
try:
logoStatus = requests.request('GET', logo)
feedStatus = requests.request('GET', feed)
except requests.exceptions.ConnectionError:
Rather than stopping at the exception handler, the code stops and displays the following:
Exception has occurred: ConnectionError HTTPConnectionPool(host='some.web.com', port=80): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f33d102f978>: Failed to establish a new connection: [Errno -2] Name or service not known',))
I referred to Correct way to try/except using Python requests module? in trying to code this, but, it doesn't seem to work for me.
Can someone point out what I'm doing wrong?