1

I am trying to read in the HTML code for a website into R but I keep encountering an error

> data=readLines("www.google.com")
Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") :
  cannot open file 'www.google.com': No such file or directory

I tried to the following command prior to establish a connection.

> setInternet2(TRUE)
Error: 'setInternet2' is defunct.
See help("Defunct")

I also tried installing the library and updating R but with no luck.

library(installr)
updateR()

What do I need to get R to load the HTML code?

jessica
  • 1,325
  • 2
  • 21
  • 35
  • You need to add the "http://" to properly specify a url address. Also take a look at the `rvest` package for reading a parsing html code. – Dave2e Feb 23 '19 at 01:48
  • Thank you! But what if your trying to access a site and you get this error message from the readLines command "Error in file(con, "r") : cannot open the connection. HTTP status was '403 Forbidden'" – jessica Feb 23 '19 at 02:00
  • Does the site require a log in? – Dave2e Feb 23 '19 at 02:05

0 Answers0