RSelenium with RSDriver. Error: httr output: Failed to connect to localhost port 4445: Connection refused
Asked Answered
Q

3

5

I am trying to use RSelenium for webscraping. I am following the basics tutorial as explained on cran. The recommended approach is to install Docker (see tutorial as well as this stackoverflow answer). If I understand correctly, this is not an option for me as I am operating on Windows 7 for which Docker seems not to be available (see docker forum).

Thus, I am trying option 2 using the RSDriver. I run

RSelenium::rsDriver()

remDr <- remoteDriver(
  remoteServerAddr = "localhost",
  port = 4445L,
  browserName = "firefox"
)
    
remDr$open()

and get the error

> remDr$open()
[1] "Connecting to remote server"
Error in checkError(res) : 
  Undefined error in httr call. httr output: Failed to connect to localhost port 4445: Connection refused

This question has been asked and answered before here, here, here and here, though these are about the same error when using Docker and their solutions did not work for me.

Is there anyway to get this running with rsDriver? Is there any option for me as a Windows 7 user?

Quip answered 16/10, 2019 at 9:38 Comment(2)
I have exactly the same problem. Were you able to resolve it?Contemporaneous
Late answer: No, for me the problem is still unsolved. I went with Python Selenium in the end.Quip
F
0

With RSelenium version 1.7.7 this is a workaround:

library(RSelenium)

remDr <- rsDriver(
  port = 4445L,
  browser = "firefox"
)

This command combines the server setup, and driver initation.

Falco answered 15/5, 2020 at 20:7 Comment(0)
L
0

My issue (on Mac) was updating Java:

https://www.oracle.com/java/technologies/downloads/#jdk19-mac

Worked after this.

Lilylilyan answered 30/11, 2022 at 19:15 Comment(2)
The question specifies being on Windows, and answers should be more than just a linkAutosome
Posted a Mac solution as this question would be marked as a duplicate if asked specifically for Mac. The answer is to install the software from the link to get a resolution.Lilylilyan
M
0

Yiou could consider the two following approaches to use RSelenium :

library(RSelenium)

shell('docker run -d -p 4446:4444 selenium/standalone-firefox') # Docker has to be installed
remDr <- remoteDriver(remoteServerAddr = "localhost", port = 4446L, browserName = "firefox")
remDr$open()
remDr$navigate("https://www.my_Website.com")
library(RSelenium)
library(wdman)

port <- as.integer(4444L + rpois(lambda = 1000, 1))
pJS <- wdman::phantomjs(port = port)
remDr <- remoteDriver(browserName = "phantomjs", port = port)
remDr$open()
remDr$navigate("https://www.my_Website.com")
Mold answered 17/4, 2023 at 14:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.