I want to expand t.co short links into a full URL. How can I do that?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
The easiest way in python2 is to use
urllib2.urlopen()
:will print the URL
tco_url
finally resolves to, after following all redirects.Using requests, you could write:
You should be able to use Twitter's API. Each tweet has a JSON representation; reading JSON from Python is straightforward.
One of the entities contained in the JSON is
expanded_url
, defined as "The fully resolved URL".