I’m using the urllib2.urlopen method to open a URL and fetch the markup of a webpage. Some of these sites redirect me using the 301/302 redirects. I would like to know the final URL that I’ve been redirected to. How can I get this?
I’m using the urllib2.urlopen method to open a URL and fetch the markup of
Share
Call the
.geturl()method of the file object returned. Per theurllib2docs:Example: