Skip to content

Instantly share code, notes, and snippets.

@fangzhou-xie
Last active October 2, 2021 01:25
Show Gist options
  • Save fangzhou-xie/d73f7d79c9c6f570cca6465fb4a0f078 to your computer and use it in GitHub Desktop.
Save fangzhou-xie/d73f7d79c9c6f570cca6465fb4a0f078 to your computer and use it in GitHub Desktop.
Tor in R
# set fresh_connect to force not using old connection (so that ip address could refresh per 10secs)
# depends on how you set up the refresh ip for Tor service
h <- curl::new_handle(proxy = "socks5://localhost:9050", maxage_conn = 10) # , fresh_connect = 1)
curl::handle_setheaders(h, "Cache-Control" = "no-cache", "User-Agent" = Randomuseragent::random_useragent())
req <- curl::curl_fetch_memory("https://icanhazip.com/", handle = h)
rawToChar(req$content)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment