What I'm trying to do
I'm requesting a file from an API. If the file does't exist, I get a 404.
What I tried
I'm trying to handle this, using urllib3
.
I found a lot of great, but outdated (~10 years old), documentation how to do this with with urllib
and urllib2
.
How does this work in urllib3
?
All I found in their docs was this
try:
http.request('GET', 'nx.example.com', retries=False)
except urllib3.exceptions.NewConnectionError:
print('Connection failed.')