0

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")
Tretecou
  • 5
  • 4
  • What are you trying to scrape? List of brands? – Chamkrai Feb 11 '23 at 13:10
  • Ye, like all models and such... every info like cpu, display about every model from every brand... Just gotta change proxies, it can identify where it left off by analyzing the file with the models... – Tretecou Feb 11 '23 at 13:30
  • Are you unable to scrape without changing the proxy? – Chamkrai Feb 11 '23 at 14:03
  • Yes, unable to scrape without changing a proxy. But my concern is the error in the title of the thread - Error in value[[3L]](cond) : no loop for break/next, jumping to top level. -=> It happens at response <- GET i think - but starts at response <- tryCatch since it is its parent. – Tretecou Feb 12 '23 at 09:57

0 Answers0