I'm using urllib2 to request a particular S3 bucket at
urllib2.HTTPError: HTTP Error 301: Moved Permanently
import urllib2, httplib
request = urllib2.Request(site)
response = urllib2.urlopen(request)
You are better off using the
requests handle redirection by default : http://docs.python-requests.org/en/latest/user/quickstart/#redirection-and-history
import requests response = requests.get(site) print(response.content)
I don't get the problem with urllib2, I tried to look into the documentation https://docs.python.org/2/library/urllib2.html but it doesn't look intuitive.
It seems that in Python3, they refactored it to make it less a burden to use, but I am still convinced that
requests is the way to go.
Note The urllib2 module has been split across several modules in Python 3 named urllib.request and urllib.error. The 2to3 tool will automatically adapt imports when converting your sources to Python 3.