How can I use a loop to scrape website data for multiple webpages in R?

前端 未结 3 1793
無奈伤痛
無奈伤痛 2021-01-19 04:50

I would like to apply a loop to scrape data from multiple webpages in R. I am able to scrape the data for one webpage, however when I attempt to use a loop for multiple page

3条回答
  •  悲&欢浪女
    2021-01-19 05:20

    This is what I did. It is not the best solution, but you will get an output. Also this is only a workaround. I do not recommend you write a table output into a file while running a loop. Here you go. After the output is generated from stats,

    output<-rbind(stats,i)
    

    and then write the table to,

    write.table(output, file = "D:\\Documents\\HTML\\Test of loop.csv", row.names = FALSE, append = TRUE, sep = ",")
    
    #then close the loop
    }
    

    Good luck

提交回复
热议问题