Reputation: 267140
I want to download an image file from potentially 5 sites.
Meaning that if the image wasn't found in site#1, try site#2, etc.
How can I test if the file was downloaded?
Upvotes: 1
Views: 172
Reputation: 33789
You can call getcode()
on the object you get back from urlopen()
.
getcode()
gives you the HTTP status response from the server, so you can test to see if you got an HTTP 200 response, which would mean the download was successful.
Upvotes: 3