To use RSelenium and PhantomJS for web scraping, we need Selenium and PhantomJS executables.

Some useful ref:
http://cran.r-project.org/web/packages/RSelenium/vignettes/RSelenium-headless.html
http://johndharrison.github.io/RSOCRUG/

1. Can’t remember exactly, but doing this should be able to automatically install Selenium binary.

#install.packages('RSelenium')
library(RSelenium)
## Loading required package: RCurl
## Loading required package: bitops
## Loading required package: RJSONIO
## Loading required package: XML
#startServer()

2. download phantomjs binary from their website

phantomjs didn’t work on Mac OSX Yosemite. Refer to this
http://stackoverflow.com/questions/28267809/phantomjs-getting-killed-9-for-anything-im-trying
The second way worked well, which was essentially:

$ brew install upx
$ upx -d phantomjs-2.0.0-macosx/bin/phantomjs

Test:

library(RSelenium)

pJS <- phantom(pjs_cmd = "/Users/Nan/bin/installs/phantomjs-2.0.0/bin/phantomjs")
remDr <- remoteDriver(browserName = 'phantomjs')
remDr$open()
remDr$navigate("http://www.google.com/ncr")
remDr$getTitle()[[1]] # [1] "Google"
remDr$close()
pJS$stop()

Not run because it didn’t work well with RMarkdown.