I am using decode_short_url
of the twitteR
package to decode shortened URLs from Twitter posts, but I am not able to get the desired results, It is always giving back the same results such as:
decode_short_url(decode_short_url("http://bit.ly/23226se656"))
## http://bit.ly/23226se656
## [1] "http://bit.ly/23226se656
UPDATE I wrapped this functionality in a package and managed to get it on CRAN same-day. Now, you can just do:
You can pass in a vector of URLs and get a
data_frame
/data.frame
back in that form.That particular bit.ly URL gives a
404
error. Here's a version ofdecode_short_url
that has an optionalcheck
parameter that will attempt aHEAD
request and throw a warning message for any HTTP status other than 200.You can further modify it to return
NA
in the event the "expanded" link 404's (I have no idea what you need this to really do in the event the link is bad).NOTE that the addd
HEAD
request will significantly slow the process down, so you may want to do a first pass withcheck=FALSE
to a separate column, then compare which weren't "expanded", then check those withcheck=TRUE
.You might also want to rename this to avoid namespace conflicts with the one from
twitteR
.