tags:

views:

29

answers:

2

I'm using the urllib2.urlopen method to open an url and fetch the markup of a webpage. Some of these sites redirect me using the 301/302 redirects. I would like the know the final URL that I've been redirected to. How can i get this?

Thanks

+1  A: 

Call geturl() on the file object returned see the python docs

Mark
A: 

The return value of urllib2.urlopen has a geturl() method which should return the actual (i.e. last redirect) url.

Michael