urllib2 and HTTP 302

Discussion in 'Python' started by Laszlo Nagy, May 26, 2006.

  1. Laszlo Nagy

    Laszlo Nagy Guest

    Hello,


    The code below uses urllib2 and build_opener. Having this code fragment,
    how can I return the redirection URL?
    I tried to get this information from the exception but I could not. Is
    it possible to read it from the openerdirector?
    Any suggestions?


    try:
    self.post_multipart(
    url,
    [('uploadType','Inventory')],
    [('uploadFileName','inv.txt',fdata)]
    )
    except urllib2.HTTPError, e:
    if e.code == 302:
    return "I would like to get the URL to be redirected
    to...."
    else:
    raise

    Thanks,

    Laszlo
    Laszlo Nagy, May 26, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. hendy
    Replies:
    0
    Views:
    737
    hendy
    Dec 20, 2005
  2. =?ISO-8859-1?Q?Eino_M=E4kitalo?=

    urllib2 and Set-Cookie with "302 Moved temporarily"

    =?ISO-8859-1?Q?Eino_M=E4kitalo?=, Dec 13, 2004, in forum: Python
    Replies:
    2
    Views:
    813
    =?ISO-8859-1?Q?Eino_M=E4kitalo?=
    Dec 13, 2004
  3. John J. Lee

    Re: urllib2 and HTTP 302

    John J. Lee, Jun 1, 2006, in forum: Python
    Replies:
    1
    Views:
    414
    John J. Lee
    Jun 5, 2006
  4. hendy
    Replies:
    0
    Views:
    206
    hendy
    Dec 20, 2005
  5. hendy
    Replies:
    1
    Views:
    249
    Bob Barrows [MVP]
    Dec 20, 2005
Loading...

Share This Page