Closed joshuawn closed 8 years ago
I think I'm planning on switching over to requests, as that appears to be the more "modern" way to do things.
I have changed from urllib to requests as requests seems to be best practice.
Also it seems to have worked better for one of the guys raising an issue.
The error module is a new addition meant for Python 3. An equivalent for urllib.error.HTTPError in Python 2.x would be to use urllib2.HTTPError A solution would be to check the version of Python used to run the script (sys.version) and write conditionals to determine imports and modules. An example can be found here: http://stackoverflow.com/questions/1875259/importing-a-module-based-on-installed-python-version
You may also want to handle multiple errors at once, since urllib.urlretrieve can also produce an OSError if a connection cannot be established.
For instance,