html 跨页面 列表,html – R跨越多个页面的网页抓取

如果您希望将所有信息作为data.frame,您可以使用purrr :: map_df()执行类似的操作:

library(rvest)

library(purrr)

url_base

map_df(1:39, function(i) {

# simple but effective progress indicator

cat(".")

pg

data.frame(wine=html_text(html_nodes(pg, ".review-listing .title")),

excerpt=html_text(html_nodes(pg, "div.excerpt")),

rating=gsub(" Points", "", html_text(html_nodes(pg, "span.rating"))),

appellation=html_text(html_nodes(pg, "span.appellation")),

price=gsub("\\$", "", html_text(html_nodes(pg, "span.price"))),

stringsAsFactors=FALSE)

}) -> wines

dplyr::glimpse(wines)

## Observations: 1,170

## Variables: 5

## $wine (chr) "Charles Smith 2012 Royal City Syrah (Columbia Valley (WA)...

## $excerpt (chr) "Green olive, green stem and fresh herb aromas are at the ...

## $rating (chr) "96", "95", "94", "93", "93", "93", "93", "93", "93", "93"...

## $appellation (chr) "Columbia Valley", "Columbia Valley", "Columbia Valley", "...

## $price (chr) "140", "70", "70", "20", "70", "40", "135", "50", "60", "3...

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值