How to get the URL of a redirect with Python

You can easily get D by just asking for the current URL.

req = urllib2.Request(starturl, datagen, headers)
res = urllib2.urlopen(req)
finalurl = res.geturl()

To deal with the intermediate redirects you’ll probably need to build your own opener, using HTTPRedirectHandler that records the redirects.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)