【发布时间】:2015-09-06 09:55:06
【问题描述】:
我正在尝试使用 rvest 来学习使用 R 进行网页抓取。我正在尝试为页面的其他几个部分复制乐高示例,并使用 selector gadget 来标识。
我从R Studio tutorial 中提取了示例。使用下面的代码,1 和 2 有效,但 3 无效。
library(rvest)
lego_movie <- html("http://www.imdb.com/title/tt1490017/")
# 1 - Get rating
lego_movie %>%
html_node("strong span") %>%
html_text() %>%
as.numeric()
# 2 - Grab actor names
lego_movie %>%
html_nodes("#titleCast .itemprop span") %>%
html_text()
# 3 - Get Meta Score
lego_movie %>%
html_node(".star-box-details a:nth-child(4)") %>%
html_text() %>%
as.numeric()
【问题讨论】: