0

I am trying to use RSelenium with Dockerto crawl a website. However, I have some issues trying to get RSelenium/Docker to work.

Specifically, I installed Docker on my computer, which appears to be running fine (I see the image of the whale below when I open it).

Docker screenshot

In R, I then run the following code with no problems and see the expected output.

shell('docker run -d -p 4445:4444 selenium/standalone-chrome')
shell('docker ps')
CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS              PORTS                    NAMES
d7de815ce644        selenium/standalone-chrome   "/opt/bin/entry_poin…"   13 minutes ago      Up 13 minutes       0.0.0.0:4445->4444/tcp   zen_mclean

But when I then run the following code, I always receive the following error message:

remDr <- RSelenium::remoteDriver(remoteServerAddr = "localhost",
                             port = 4444,
                             browserName = "chrome")
remDr$open()
[1] "Connecting to remote server"
Error in checkError(res) : 
  Undefined error in httr call. httr output: Failed to connect to localhost port 4444: Connection refused

I am not sure what is going on here (I'm new to scraping). Can anybody help me figure out what to do here?

If it helps, I am running Windows 10.

David Metcalf
  • 664
  • 1
  • 7
  • 13

2 Answers2

0

In docker, you've binded your hosts port 4445 to the selenium-driver port 4444.

Which means if you run R in your host, you need to specify port = 4445

Does that solve it?

Emil Bode
  • 1,784
  • 8
  • 16
0

I managed to solve the problem by uninstalling Docker Toolbox and VMBox, which I was using, and installing the latest version of Docker from their website instead.

David Metcalf
  • 664
  • 1
  • 7
  • 13