8

I use this code

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

And I take back this error

Error: could not find function "read_html"

Any idea what's going wrong with this?

Also in case of multiple links like this

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"
)

I receive this:

 Error: is.config(config) is not TRUE

How can I make it to work? How is it if I have this links into a txt file?

zx8754
  • 42,109
  • 10
  • 93
  • 154
Demi Kalia
  • 123
  • 1
  • 1
  • 9
  • 2
    The function used to be called `html()`. You're probably using a version of `rvest` where that version of the function name still exists. Try `html()` instead. – MrFlick Jun 20 '15 at 16:38
  • You need to use tools like `lapply` to parse multiple urls. : `lapply(urls, function(j),html(j))`. – user227710 Jun 20 '15 at 18:19

1 Answers1

12

The documentation probably referred to the read_html() function in the xml2 package which is written by the same author, Hadley Wickham, after the initial publication of the rvest package.

Therefore, you will have to install and load the xml2 package as follows:

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

url<-read_html("http://en.wikipedia.org/wiki/Brazil_national_football_team")
yxtay
  • 436
  • 4
  • 11