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?
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?
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.