user_agents <-"https://raw.githubusercontent.com/fake-useragent/fake-useragent/master/src/fake_useragent/data/browsers.json"%>%read_html() %>%html_text() %>%str_extract_all("\\{.+?\\}") %>%pluck(1) %>%map_dfr(~fromJSON(.) |>as_tibble_row())nrow(user_agents) # there are 52 user agents in total
[1] 52
Get a fake user agent randomly.
Code
sample_n(user_agents, 1) %>%select(useragent)
useragent
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 Edg/116.0.1938.81