Given a t.co link, how can I find see where the link resolves? For example, if I have t.co/foo, I want a function or process that returns domain.com/bar.
相关问题
- Rails how to handle error and exceptions in model
- CORS issue with Twitter api calls in Webpack dev s
- Twitter sign in crashes with TWTRInvalidInitializa
- Accessing Twitter through Javascript
- Swift 3: How to reverse a transparent Navigation B
相关文章
- is there a callback option with twitter's “fol
- Twitter name length in DB
- Twitter oauth refresh token
- Login with Twitter on iOS
- linqtotwitter - grab the saved credentials
- Getting the location using Tweepy
- Making any tweet favourite through iOS 5 twitter A
- How to obscure the id in a url (ruby on rails) [du
Another Python solution, this time relying on the requests module instead of urllib2 (and all the rest of those libraries):
Here is an R solution, ported from other answers in this thread, and from
example()
code of the RCurl Package:You could give unshorten.me a go. It has an API.
JSON:
http://api.unshort.me/?r=http://theshorturl.ly/28292&t=json
Would give you:
You may try this Java code. Such is a code use the HttpURLConnection owned by java. : http://www.srccodes.com/p/article/37/expand-shortened-link-using-java?fb_action_ids=1544985322486585&fb_action_types=og.likes
How this URL Expander will work? Make HttpURLConnection to the shortened url (say http://goo.gl/WT6eFw).
Extract the value of HTTP header field "Location". And this value is nothing but the expanded or actual destination URL.
Close the connection.
Here is a Python solution.
Tested with an actual twitter t.co link:
expanded = http://twitter.com/shanselman/status/276958062156320768/photo/1
Wrap it up with a try-except and you are good to go.
curl -s -o /dev/null --head -w "%{url_effective}\n" -L "https://t.co/6e7LFNBv"
--head
or-I
only downloads HTTP headers-w
or--write-out
prints the specified string after the output-L
or--location
follows location headers