urllib2 redirect error

Sumit Ray sumitbu.ray at gmail.com
Tue Sep 2 08:08:47 CEST 2014


 I've tried versions of the following but continue to get errors:

------------- snip -------------
url = 'https://www.usps.com/send/official-abbreviations.htm'
request = urllib2.build_opener(urllib2.HTTPRedirectHandler).open(url)
------------- snip -------------

Generates an exception:
urllib2.HTTPError: HTTP Error 301: The HTTP server returned a redirect
error that would lead to an infinite loop.
The last 30x error message was:
Moved Permanently

The following using the requests library hangs:
------------- snip -------------
response = requests.get(url)
------------- snip -------------

I'm fresh out of ideas and any suggestions you may have would be greatly

Thanks in advance,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20140902/6a10bb44/attachment.html>

More information about the Python-list mailing list