0

I scraped a website already and made a dataframe from it that only contains a column called "racenames" in this example. Each row has its own link that works if I were to take it and put it into a browser, this column is called "realtest.Event". How do I create a scraper that goes through my dataframe of links one by one? I'm not sure if a for loop is the way to go about this or not. If I can use a for loop, what am I doing wrong?


res_all <- NULL

for (realtest.Event in racename) {
    urlrunning = paste0(realtest.Event)
    
  scrapinghere = read_html(urlrunning)
    
  putithere <- tibble(
      bubba = scrapinghere %>% html_nodes("#sites-canvas-main-content td:nth-child(2)") %>% html_text(),
      bubba2 = scrapinghere %>% html_node("#sites-canvas-main-content td:nth-child(1)")) %>% html_text()
  
  
  res_all <- bind_rows(res_all, putithere)
  }

My error I'm currently getting is... Error: x must be a string of length 1

  • https://stackoverflow.com/a/68369554/10276092 and https://stackoverflow.com/a/74781628/10276092 – M.Viking Dec 20 '22 at 00:51
  • Does this answer your question? [Rvest: Scrape multiple URLs](https://stackoverflow.com/questions/36922087/rvest-scrape-multiple-urls) – shs Dec 20 '22 at 01:11

0 Answers0