1

我正在尝试在 goodreads 上抓取评分和评论数字,但得到的是 NA 结果。为什么是这样?

SelectorGadget 为悬停时的平均评分找到“跨度跨度”,但在底部没有找到“有效路径”。

在其他网站(例如 IMDB、theatlantic.com)上使用相同的方法效果很好。

这是我的代码和结果(我也尝试用 html_tag 替换 html_text)

 Rating<- html("http://www.goodreads.com/book/show/22444789-delicious-foods")

Rating %>%
 html_node("span span") %>%
 html_text () %>%
 as.numeric()
[1] NA
Warning message:
In function_list[[k]](value) : NAs introduced by coercion
4

1 回答 1

1

我在 Goodreads 网站上使用 selectorgadget 并没有取得任何成功,但有时您只需查看 html 源代码并以这种方式找到您要查找的内容。

在这种情况下,您可以使用 .average 类选择器:

Rating %>%
 html_node(".average") %>%
 html_text %>%
 as.numeric
于 2015-03-11T21:28:02.987 回答