I have the following code that takes shortened Twitter links and returns the actual long-form link and the status code as a tibble. My gut is telling me that I don't need to repeat myself by using map()
and map_df()
piped together.
Is there a better way to do this?
Reprex:
library(tidyverse)
library(httr)
urls <- c("https://t.co/jM8oizOCHs", "https://t.co/B5BS9Ad2na", "https://t.co/ZXER3i6BvQ")
map(urls, httr::GET) %>%
map_df(., magrittr::extract, c("url", "status_code"))
#> # A tibble: 3 x 2
#> url status_code
#> <chr> <int>
#> 1 https://github.com/r-lib/vctrs 200
#> 2 https://peerj.com/preprints/3159/?utm_content=bufferc4f11&u~ 200
#> 3 https://archervisualization.herokuapp.com/?utm_content=buff~ 200
Example links grabbed from @mara 's Twitter