我不能用Rselenium得到任何好处。这是第一步,也是我的输出:
library(RSelenium) rD <- rsDriver() # checking Selenium Server versions: # BEGIN: PREDOWNLOAD # BEGIN: DOWNLOAD # BEGIN: POSTDOWNLOAD # checking chromedriver versions: # BEGIN: PREDOWNLOAD # BEGIN: DOWNLOAD # BEGIN: POSTDOWNLOAD # checking geckodriver versions: # BEGIN: PREDOWNLOAD # BEGIN: DOWNLOAD # BEGIN: POSTDOWNLOAD # checking phantomjs versions: # BEGIN: PREDOWNLOAD # BEGIN: DOWNLOAD # BEGIN: POSTDOWNLOAD # [1] "Connecting to remote server" # Error in checkError(res) : # Undefined error in httr call. httr output: Failed to connect to localhost port 4567: Connection refused # In addition: Warning message: # In rsDriver() : Could not determine server status.
我错过了什么 ?
尝试运行不建议使用的checkForServer()Selenium时,有两种选择:
checkForServer()
看到:
RSelenium::checkForServer() # Error: checkForServer is now defunct. Users in future can find the function in # file.path(find.package("RSelenium"), "examples/serverUtils"). The # recommended way to run a selenium server is via Docker. Alternatively # see the RSelenium::rsDriver function.
大家似乎 对发生问题rsDriver和码头工人是推荐的选项,所以我们走的这条路:
docker pull selenium/standalone-firefox
chrome
firefox
shell('docker pull selenium/standalone-firefox')
docker run -d -p 4445:4444 selenium/standalone-firefox
shell('docker run -d -p 4445:4444 selenium/standalone-firefox')
remDr <- remoteDriver(remoteServerAddr = "localhost", port = 4445L, browserName = "firefox'")
设置了这个,这是我的代码:
shell('docker run -d -p 4445:4444 selenium/standalone-firefox') remDr <- remoteDriver(remoteServerAddr = "localhost", port = 4445L, browserName = "firefox") remDr$open() remDr$navigate("http://www.google.com/ncr") remDr$getTitle() # [[1]] # [1] "Google"
有关更多信息的文档: