我想扩展成一个完整的网址t.co短链接。我该怎么做呢?
发布于 2012-01-16 02:45:45
您应该能够使用Twitter的API。每条推文都有a JSON representation;正在读取JSON from Python is straightforward。
其中一个网址是expanded_url
,定义为“完全解析的entities contained in the JSON”。
发布于 2012-01-16 02:38:13
在python2中最简单的方法是使用urllib2.urlopen()
tco_url = "http://t.co/whatever"
req = urllib2.urlopen(tco_url)
print req.url
在遵循所有重定向之后,将打印tco_url
最终解析到的URL。
发布于 2012-01-16 02:41:46
使用requests,你可以这样写:
>>> import requests
>>> print(requests.get("http://t.co/UVgwaemZ").url)
http://paper.li/vascoda/vascoda-partner
https://stackoverflow.com/questions/8872232
复制相似问题