So im trying to create a iteration through a list of proxies - now just a bunch in a list... I created this code with some internet help to switch proxies when they encounter error 429. But it does the error and i cant just seem to figure it out in any way. Thanks in advance! I have seen some similar questions and answers here, but i unfortunately cannot figure my problem out of the other answers as R is still new to me. Theres an issue with the loop but dont know where.
build_oem_table <- function(...) {
proxies <- c("203.24.108.170:80", "172.67.182.165:80", "45.12.30.84:80", "203.28.8.207:80")
for (i in seq_along(proxies)) {
proxy <- proxies[i]
response <- tryCatch({
response <- GET("https://www.gsmarena.com/", config(proxy = paste0("http://", proxy)))
if (status_code(response) != 429) {
break
}
}, error = function(e) {
next
})
if (status_code(response) != 429) {
break
}
}
if (status_code(response) == 429) {
stop("All proxies failed with HTML error 429")
}
sesh <- session("https://www.gsmarena.com/makers.php3")
makers <- read_html(sesh)
makers <- read_html("C:\\Users\\dex\\Downloads\\gsm\\List of all mobile phone brands - GSMArena.com.html")