使用Chrome在MacBook上安装RSelenium

时间:2018-06-15 18:09:02

标签: r macos selenium rselenium

我安装了RSelenium(包),从hockeyreference.com上做一些NHL统计数据的抓取

它工作正常,但最近停止工作,发出此错误:

[1] "Connecting to remote server"
Could not open chrome browser.
Client error message:
Undefined error in httr call. httr output: Failed to connect to 
localhost port 4567: Connection refused
Check server log for further details.

$client
[1] "No sessionInfo. Client browser is mostly likely not opened."

$server
Process Handle
command : /private/var/folders/dk/kf4tf83n1lg40687w6fmq5wh0000gn/T/Rtmpiy1cOY/file1d1856ef53ae.sh 
system id : 18786
state     : exited
Warning message:
In rsDriver(port = 4567L, geckover = NULL, phantomver = NULL) :
   Could not determine server status.

我已尝试重新安装,但无法使其正常运行。我在这个问题中概述了我的原始安装(使用自制程序,安装了最新的chromedriver):

Css selector issue with rvest and NHL statistics

任何帮助都会很棒。与RSelenium一起运行的代码在这里:

https://github.com/papelr/nhldatar/blob/master/nhldatar/R/nhldatar-phase-2.R

TL; DR,我无法获得rsDriver参数,并且它会在上面发布错误:

rsDriver(port = 4567L, geckover = NULL, phantomver = NULL)
remDr <- remoteDriver(browserName = "chrome")
remDr$open()

如果RSelenium正常工作(打开Chrome浏览器),那么剩下的就会运行!谢谢!

1 个答案:

答案 0 :(得分:2)

我建议:

  • 为Mac安装docker,

  • 将图片拉为chrome,firefox(推荐版本3.5.1)或幻像

  • 在docker中运行图片:docker run ...

  • 创建remotedriver:

    remDr&lt; - remoteDriver(remoteServerAddr =“here you IP”,port = 4445L,                         browserName =“firefox”)

  • 如果你有调试版,你可以在VNC中观看你在做什么