Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 515
Monica Avatar asked Feb 28 '23 11:02

Monica


1 Answers

>>> import urllib2
>>> var = urllib2.urlopen('http://www.stackoverflow.com/')
>>> var.geturl()
'http://stackoverflow.com/'
like image 194
Bertrand Marron Avatar answered Apr 26 '23 10:04

Bertrand Marron