Monica
Monica

Reputation: 43

How can I determine the final URL after redirection using python / urllib2?

I need to get the final URL after redirection in python.

What's a good way to do that?

Upvotes: 4

Views: 2542

Answers (1)

Bertrand Marron
Bertrand Marron

Reputation: 22210

>>> import urllib2
>>> var = urllib2.urlopen('http://www.stackoverflow.com/')
>>> var.geturl()
'http://stackoverflow.com/'

Upvotes: 8

Related Questions