Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unwrap t.co links with R

Tags:

r

twitter

I'm looking to unwrap t.co (for Twitter's shortened URL) links using R.

Here's an example of one: http://t.co/Xvb6T3KyHr

Here's the unwrapped URL: http://www.donorschoose.org/project/we-need-technology-in-physical-education/1684466/?utm_source=dc&utm_medium=project&utm_campaign=twitter&rf=twitter-siteshare-2015-09-project-teacher_3103521

There are answers for Python and JS, but as far as I can tell none for R.

like image 553
Joshua Rosenberg Avatar asked Jan 30 '26 02:01

Joshua Rosenberg


1 Answers

You could try

twitteR::decode_short_url("http://t.co/Xvb6T3KyHr") 

or

httr::HEAD("http://t.co/Xvb6T3KyHr")$url

There's also a package called longurl from @hrbrmstr. However, it seems as if it doesn't work with t.co links anymore.

like image 194
lukeA Avatar answered Feb 01 '26 19:02

lukeA