2012-01-15 42 views

回答

9

在python2最簡單的方法是使用urllib2.urlopen()

tco_url = "http://t.co/whatever" 
req = urllib2.urlopen(tco_url) 
print req.url 

將打印URL tco_url終於解析,以下所有重定向後。

7

使用requests,你可以寫:

>>> import requests 
>>> print(requests.get("http://t.co/UVgwaemZ").url) 
http://paper.li/vascoda/vascoda-partner