Skip to content

Instantly share code, notes, and snippets.

@joelnitta
Created November 18, 2022 11:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joelnitta/164e66c82e30d54c036efc8ed236bb02 to your computer and use it in GitHub Desktop.
Save joelnitta/164e66c82e30d54c036efc8ed236bb02 to your computer and use it in GitHub Desktop.
Archive a user's friends on twitter
library(rtweet)
# Initial authorization setup, only need to do once
# auth_setup_default() #nolint
# Authorize
auth_as("default")
# Set user name
user_name <- "PUT USER NAME HERE"
# Get list of friends (users followed)
my_friends <- get_friends(
user_name,
n = 5000,
retryonratelimit = FALSE,
parse = TRUE,
verbose = TRUE)
# Get friends' data
my_friends_data <- lookup_users(
my_friends$to_id,
parse = TRUE,
retryonratelimit = FALSE
)
# Save friends' data
saveRDS(my_friends_data, "my_friends_data.RDS")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment