【问题标题】:Error: could not find function "read_html"错误:找不到函数“read_html”
【发布时间】:2015-09-06 12:17:24
【问题描述】:

我用这个代码

library(rvest)
url<-read_html("http://en.wikipedia.org/wiki/Brazil_national_football_team")

我收回这个错误

Error: could not find function "read_html"

知道这是怎么回事吗?

如果有多个这样的链接

library(rvest)
urls<-html("https://en.wikipedia.org/wiki/Financial_crisis",
"https://en.wikipedia.org/wiki/Inflection",
"https://en.wikipedia.org/wiki/Financial_crisis_of_2007%E2%80%9308"
)

我收到这个:

 Error: is.config(config) is not TRUE

我怎样才能让它工作?如果我有这个链接到 txt 文件中会怎样?

【问题讨论】:

  • 该函数曾经被称为html()。您可能正在使用 rvest 的版本,该版本的函数名称仍然存在。请改用html()
  • 你需要使用lapply之类的工具来解析多个url。 :lapply(urls, function(j),html(j)).

标签: r rvest


【解决方案1】:

该文档可能引用了xml2 包中的read_html() 函数,该函数由同一作者Hadley Wickham 在rvest 包最初发布后编写。

因此,您必须按如下方式安装和加载xml2 包:

install.packages('xml2')
library('xml2')

url<-read_html("http://en.wikipedia.org/wiki/Brazil_national_football_team")

【讨论】:

    猜你喜欢
    • 2020-12-18
    • 2017-01-14
    • 2019-08-17
    • 2015-07-26
    • 2018-07-31
    • 2016-05-20
    相关资源
    最近更新 更多