如何使用 rvest 从网页中提取选择性数据?

Ish*_*edi 1 html r web-scraping rvest

我一直在尝试使用来自Pitchfork https://pitchfork.com/reviews/albums/us-girls-heavy-light/ 的rvest in r 来显示这首歌的评论评级。在这种情况下,它是 8.5。但不知何故我得到了这个: 在此处输入图片说明

这是我的代码

library(rvest)
library(dplyr)
library(RCurl)
library(tidyverse)

URL="https://pitchfork.com/reviews/albums/us-girls-heavy-light/"

webpage = read_html(URL)


cat("Review Rating")
webpage%>%
   html_nodes("div span")%>%
   html_text
Run Code Online (Sandbox Code Playgroud)

Ron*_*hah 5

我们可以从divis的类中获取相关信息"score-circle"

library(rvest)

webpage %>% html_nodes('div.score-circle') %>% html_text() %>% as.numeric()
#[1] 8.5
Run Code Online (Sandbox Code Playgroud)