运维开发网
广告位招商联系QQ:123077622
 
广告位招商联系QQ:123077622

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

运维开发网 https://www.qedev.com 2020-06-11 18:52 出处:网络 作者:运维开发网整理
R selenium无法到达任何地方.这是第一步和我的输出: library(RSelenium) rD <- rsDriver() # checking Selenium Server versions: # BEGIN: PREDOWNLOAD # BEGIN: DOWNLOAD # BEGIN: POSTDOWNLOAD # checking chromedriver versions:
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", port = 4445L, 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

扫码领视频副本.gif

0

精彩评论

暂无评论...
验证码 换一张
取 消