Search code examples
pythonapitwitter

How to expand t.co URLs in tweets with python


I wrote program in python that extract links that are in tweets and that are in t.co/xxxxx format i want to convert links to unshorten format i use below code

tmep= urlopen(url)  
full_url=temp.geturl()

but it isn't fast and because want to open page use much bandwidth and most of time it return erros.I cant't find any API from twitter that can expand url.anybody have solution for this problem?


Solution

  • Get the expanded_url from the Tweet object instead of the url - that will automatically give you the full URL.