我试图从多个网址中抓取一些数据,如下面的代码所示。问题在于,尽管放置了生成3个URL的脚本,但输出仅给我一个URL的数据。
#Loading the rvest package
library('rvest')
#Specifying the url for desired website to be scraped
page <- list()
inshows = c("100","200","400")
for(u in inshows) {
url <- paste0('https://www.imdb.com/search/title?title_type=feature&release_date=2016-01-01,2016-12-31&count=100&start=', u,'&ref_=adv_nxt')
page[[u]] <- read_html(url)
}
#Reading the HTML code from the website
webpage <- read_html(url)
#Using CSS selectors to scrap the rankings section
wanted_data_html <- html_nodes(webpage,'.text-primary')
#Converting the ranking data to text
wanted_data <- html_text(wanted_data_html)