3

I am trying to use the selenium/standalone-chrome Docker image, RSelenium, and an RScript to setup some automated web-scraping via my mac's command line. While the code below will work in RStudio, it won't work when I try to run it via RScript...I have tried to google and github my way to a solution, but haven't had any luck...the error I see is:

Error in checkError(res) : Undefined error in httr call. httr output: Empty reply from server

I'm wondering if anyone else has run into this issue, and what they did to resolve it? If it helps, I do intend to run this on either Ubuntu/Amazon linux one day, but I'd like to test and develop on my Mac at the moment.

Script Code

library(RSelenium)

# Kill any docker containers and start up a docker container with selenium & chrome
system('docker kill $(docker ps -q)')
Sys.sleep(2)
system('docker run -d -p 4445:4444 selenium/standalone-chrome')
Sys.sleep(2)
system('docker container ls')

remDr <- remoteDriver(remoteServerAddr = "localhost", port = 4445L, browserName = "chrome")

# Open the remote Driver
remDr$open()
# Go to Google
remDr$navigate("http://www.google.com")

# Screenshot for proof
remDr$screenshot(display=TRUE, useViewer = TRUE)

Works in RStuido:

enter image description here

Fails in RScript:

enter image description here

As always, any help is greatly appreciated. Thank you in advance.
-nate

nate
  • 1,172
  • 1
  • 11
  • 26

0 Answers0