2
私はRを使用してアマゾンウェブをスクラップし、商品の価格を入手しています。 製品は5ページに存在するので、毎回異なるURLを入力する必要があります。アマゾンウェブを掻き集めるR
pages<-c(1,2,3,4,5)
##getting the url of the 5 pages
urls<-rbindlist(lapply(pages,function(x){
url<-paste("https://www.amazon.co.uk/Best-Sellers-Health-Personal-Care-Weight-Loss-Supplements/zgbs/drugstore/2826476031#",x,sep="")
data.frame(url)
}),fill=TRUE)
product.price<-rbindlist(apply(urls,1,function(url){
locations <- url %>%
map(read_html) %>%
map(html_nodes, xpath = '//*[@id="zg_centerListWrapper"]/div/div[2]/div/div[2]/span[1]/span') %>%
map(html_text) %>%
simplify()
data.frame(locations)
}),fill=TRUE)
が100製品、各ページ内の20があり、私は何を取得していますが、最初の20を5回繰り返しです:私が使用したコードである 。 これは、最初のURLだけを入力したことを意味します。 すべてのページにアクセスするにはどうすればよいですか?ここで
おかげ