0

I've been learning R programming for the last few months and really enjoying the language. I wanted to start using it to automate a few things at work. However for the life of me no matter how much I Google or experiment I can't seem to start the browser.

I followed the steps from this article

https://www.r-bloggers.com/rselenium-a-wonderful-tool-for-web-scraping/

and got the server started from the command line. This is the code I ran in the console and the error message I'm getting.

> library(RSelenium)
> checkForServer()
Warning message:
checkForServer is deprecated.
Users in future can find the function in 
file.path(find.package("RSelenium"), "example/serverUtils").
The sourcing/starting of a Selenium Server is a users responsiblity. 
Options include manually starting a server see 
vignette("RSelenium-basics", package = "RSelenium")
and running a docker container see 
vignette("RSelenium-docker", package = "RSelenium") 

I'm running on Windows 10 64-bit and have installed the latest Firefox. Any help or pointers on this would be greatly appreciated.

Thanks, Shan

Shahnur Islam
  • 57
  • 1
  • 10

1 Answers1

0

Okay, I just went through this. So you can skip the whole Selenium Server entirely by just using phantomjs, which RSelenium can call directly.

Steps:

  1. Download phantomjs for your platform here
  2. Put this binary file in the system PATH or anywhere else you have access too from R

Now try this:

library(RSelenium)
pJS <- phantom(pjs_cmd = "<YOUR BINARY LOCATION>") # no arg if it's in PATH
Sys.sleep(5)
remDr <- remoteDriver(browserName = "phantomjs")
remDr$open(silent = T)
url <- "http://www.google.com"
remDr$navigate(url)
remDr$screenshot(display = TRUE)

NOTE: When I run this I get an error after the first step, but it still works and pulls up the page. Not sure why that happens.

Zafar
  • 1,897
  • 15
  • 33