无法执行rsDriver(连接被拒绝)

前端之家收集整理的这篇文章主要介绍了无法执行rsDriver(连接被拒绝)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

R selenium无法到达任何地方.这是第一步和我的输出

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提供了两个选项:

>使用rsDriver
>使用Docker

看到:

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.

Everybody seems to有rsDriver和Docker的问题是推荐选项,所以我们将走这条路:

> install docker
>运行它,按要求重新启动计算机
>通过在命令行中运行来拉取图像:docker pull selenium / standalone-firefox(或chrome而不是firefox)或R shell(‘docker pull selenium / standalone-firefox’)
>通过在命令行运行启动服务器:docker run -d -p 4445:4444 selenium / standalone-firefox或在R 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",browserName = "firefox")
remDr$open()
remDr$navigate("http://www.google.com/ncr")
remDr$getTitle()
# [[1]]
# [1] "Google" 

更多信息的文档:

> https://cran.r-project.org/web/packages/RSelenium/vignettes/RSelenium-basics.html
> https://cran.r-project.org/web/packages/RSelenium/vignettes/RSelenium-docker.html

原文链接:https://www.f2er.com/docker/436338.html

猜你在找的Docker相关文章