Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > urllib2 and HTTP 302

Reply
Thread Tools

urllib2 and HTTP 302

 
 
Laszlo Nagy
Guest
Posts: n/a
 
      05-26-2006

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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: urllib2 and HTTP 302 John J. Lee Python 1 06-05-2006 07:14 PM
Error ASp .NET WEb Service : URL:'http://localhost/WebService1. HTTP/1.1 302 Found" hendy ASP General 1 12-20-2005 01:45 PM
Web Service Error : URL:'http://localhost/WebService1. HTTP/1.1 302 Found" hendy ASP .Net Web Services 0 12-20-2005 08:49 AM
ASP .NET Web Service URL:'http://localhost/WebService1. HTTP/1.1 302 Found hendy ASP .Net 0 12-20-2005 08:34 AM
urllib2 and Set-Cookie with "302 Moved temporarily" =?ISO-8859-1?Q?Eino_M=E4kitalo?= Python 2 12-13-2004 09:27 PM



Advertisments