Reputation:
I was wondering if there is a convenient way via an already available Python library to convert back shortened URLs into the 'native' URLs. For example, from a list of shortened URLs:
['some url from bitly', 'shortened url from twitter', ...]
Upvotes: 1
Views: 72
Reputation: 378
Using the standard library:
import urllib2
response = urllib2.urlopen('http://shorturl')
response.geturl()
Upvotes: 1
Reputation: 430
import requests
r = requests.get("http://bit.ly/XXXX")
print r.url
r.url
will be the resolved url as returned by the server the content resides on
Upvotes: 2