urllib2 and HTTP 302

L

Laszlo Nagy

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top