4

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?

Nad Pat
  • 3,129
  • 3
  • 10
  • 20
eigenvector
  • 313
  • 1
  • 3
  • 12

3 Answers3

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.

thorepet
  • 421
  • 2
  • 9
0

My issue (on Mac) was updating Java:

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

Worked after this.

Jeff Parker
  • 1,809
  • 1
  • 18
  • 28
  • The question specifies being on Windows, and answers should be more than just a link – camille Dec 06 '22 at 19:54
  • 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. – Jeff Parker Dec 09 '22 at 18:41
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")
Emmanuel Hamel
  • 1,769
  • 7
  • 19