Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #77434

urllib2 redirect error

Date 2014-09-02 02:08 -0400
Subject urllib2 redirect error
From Sumit Ray <sumitbu.ray@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.13708.1409638130.18130.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

Hi,

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

Thanks in advance,
Sumit

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

urllib2 redirect error Sumit Ray <sumitbu.ray@gmail.com> - 2014-09-02 02:08 -0400
  Re: urllib2 redirect error Steven D'Aprano <steve@pearwood.info> - 2014-09-02 07:28 +0000
    Re: urllib2 redirect error dieter <dieter@handshake.de> - 2014-09-03 08:29 +0200
    Re: urllib2 redirect error Sumit Ray <sumitbu.ray@gmail.com> - 2014-09-06 09:24 -0700

csiph-web