【发布时间】:2017-09-03 22:04:00
【问题描述】:
我正在尝试使用最新版本的 RSelenium 连接到 Selenium 服务器。这是我使用的代码:
install.packages('RSelenium')
library(RSelenium)
remDr <- remoteDriver(remoteServerAddr = "localhost"
, port = 4445L
, browserName = "firefox"
)
remDr$open()
输出如下:
Error in checkError(res) :
Undefined error in httr call. httr output: Failed to connect to localhost port 4445: Connection refused
我已经尝试过this solution(使用 docker)。我从here 下载了 docker(因为我使用的是 macOS 10.12.5)并将可执行文件添加到 PATH。运行此代码后:
system('docker run -d -p 4445:4444 selenium/standalone-chrome')
我得到这个输出:
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
我尝试了其他一些解决方案,但都没有奏效。你能帮帮我吗?
【问题讨论】:
-
使用包含的函数运行 PhantomJS 比 Firefox/whatever 更容易。
-
试试
splashr— cran.r-project.org/web/packages/splashr/index.html & github.com/hrbrmstr/splashr。它是基于 splash.readthedocs.io/en/stable 的 Selenium 生态系统的替代品 -
话虽如此,您是否从docker.com/docker-mac 安装了 Docker,并在尝试使用 Selenium 之前验证了 Docker“hello world”示例是否有效?
-
你的 docker 守护进程没有运行。硒没有问题。可能是 docker 需要 sudo 用户权限。试试看!
标签: r docker web-scraping rselenium