我的铷突然停止了。我寻找答案,尝试了所有这些,但没有任何运气。然后我卸载了 docker 并重新安装,重新启动了我的机器等等。终于设法让一段代码工作了,所以我知道我的机器没有坏。
对我有用的代码是:
library(RSelenium)
# Specify the port
port <- as.integer(4444L + rpois(lambda = 1000, 1))
# opens a new browser
cDrv3<- rsDriver(port = port,browser = "firefox",chromever = NULL, )
remDr <- cDrv3[["client"]]
remDr$navigate("https://www.google.com")
remDr$getTitle()
remDr$closeWindow()
但是这段代码太麻烦了,每次都要下载浏览器并打开一个新的浏览器。这使得它缓慢且低效。
我想要的是让这段代码工作:
system("docker run -d -p 4445:4444 selenium/standalone-firefox:latest") # this part works.
remDr <<- remoteDriver(remoteServerAddr = "localhost", browserName = "firefox", port = 4445)
remDr$open(silent = FALSE)
当前,当我运行
remDr$open(silent = FALSE)
时,我收到以下错误:
remDr$open(silent = FALSE)
[1] "Connecting to remote server"
Error in checkError(res) :
Undefined error in httr call. httr output: Failed to connect to localhost port 5411 after 2260 ms: Couldn't connect to server
我已经尝试了所有的建议
R Rselenium“...无法连接到本地主机端口 4444:连接被拒绝”
有什么新想法可以解决我的问题吗?
提前致谢。
RSelenium 不适用于最新版本的 Selenium。要么:
docker run -d -p 4444:4444 -p 7900:7900 --shm-size="2g" selenium/standalone-firefox:4.8.3
)。您可能需要尝试找到 RSelenium 兼容的版本。