1

I'm trying to do some webscraping, but for whatever reason, RSelenium won't connect and gives me the following error message:

Error in checkError(res) : 
  Undefined error in httr call. httr output: Failed to connect to localhost port 4444: Connection refused

Here's the relevant code I'm using

#packages
packages <- c("rvest",
              "RSelenium",
              "Rcrawler",
              "stringr",
              "dplyr",
              "readxl",
              "wdman")
packages.l <- length(packages)

#install packages
for (i in 1:packages.l) {
  install.packages(packages[i])
}

#add to library
for (i in 1:packages.l) {
  library(packages[i], character.only = TRUE)
}

remDr <- remoteDriver(browserName = "chrome")
remDr$open()

I'm new to all of this, so I have no idea what the error message means much less how to fix it.

Mike
  • 11
  • 3
  • 1
    Check the error message again. Something is wrong with your connection, not the code. Check that the urls and inputs are correct. – polka Apr 12 '19 at 17:58
  • Check firewall rules and error message for [Chrome version mismatch too](https://stackoverflow.com/a/55212731/786542) – Tung Apr 12 '19 at 18:04
  • I changed the chrome driver to the closest compatible version to mine. I made sure that the firewall was allowing R through (it was). Still get the same error message. @polka I'm not sure what you mean when you say check that the urls and inputs are correct. – Mike Apr 15 '19 at 15:13
  • I tried changing my port to an open one according to netstat in my command prompt. Now I get this error `Error in resContent[["status"]] : subscript out of bounds` – Mike Apr 15 '19 at 15:52
  • 1
    I replaced the `remDr` assignment with `driver <- rsDriver(browser=c("chrome"), chromever="73.0.3683.68") remDr <- driver$client` and it works like a charm. Thanks for the help everyone. – Mike Apr 16 '19 at 14:43

0 Answers0