大家好,晚上好,RSelenium的问题
我一直在尝试使用RSelenium运行我的旧脚本。由于一些变化,它不再工作。原始代码是
require(RSelenium)
require(rvest)
RSelenium::checkForServer()
RSelenium::startServer()
remDr <- remoteDriver()
remDr$open()
remDr$navigate(linkPlayersPage)
doc <- remDr$getPageSource()
doc <- read_html(doc[[1]])
path <- "//table[@class='playersquickfindtable']/tbody/tr/td/form/table/tbody/tr/td/div/img"
quickFind <- doc %>% html_nodes(xpath=path) %>% xml_attr("alt")
remDr$close()
以下建议,我发现在这里,我改变了它以下
require(RSelenium)
require(rvest)
driver <- rsDriver()
remDr <- driver[["client"]]
remDr$navigate(linkPlayersPage)
doc <- remDr$getPageSource()
doc <- read_html(doc[[1]])
path <- "//table[@class='playersquickfindtable']/tbody/tr/td/form/table/tbody/tr/td/div/img"
quickFind <- doc %>% html_nodes(xpath=path) %>% xml_attr("alt")
remDr$close()
的事情是,它并没有真正发挥作用。或者它有时可以起作用,但首先,它非常缓慢,第二个(更重要的问题)脚本经常停止(我有一个多于11000个地址的循环)。有时在等待一段时间并从停止的地方重新运行之后,它有效,有时候根本不起作用,但我知道它应该起作用。我收到以下错误(对不起,这是英语和法语的混合,但几个法语单词不应该是很难翻译为英语的人)
Error in if (!is.null(YD) && grepl("Draft", YD)) { : valeur manquante là où TRUE/FALSE est requis
(其中TRUE/FALSE需要缺失值)
checking geckodriver versions: BEGIN: PREDOWNLOAD Error in open.connection(con, "rb") : HTTP error 403.
有时我得到一些其他错误,但10" 是最常见的。我真的不知道为什么和如何解决问题。
今天,我有一个新的错误
checking geckodriver versions: BEGIN: PREDOWNLOAD BEGIN: DOWNLOAD BEGIN: POSTDOWNLOAD checking phantomjs versions: BEGIN: PREDOWNLOAD BEGIN: DOWNLOAD BEGIN: POSTDOWNLOAD Error in subprocess::spawn_process(tfile, ...) : could not create a pipe: system error message could not be fetched
我感觉所有这些都与rsDriver()有关。
在我读答案,应提到的是做的最好的事情是不使用rsDriver()而是利用泊坞。在昨天之前,我不知道这是什么,我找不到任何能清楚解释它在R和RSelenium中如何使用它的东西......例如,这里是RSelenium through docker。我试过的链接,但网页不会显示...
任何人都可以帮助解决这个问题吗?解决我的rsDriver()问题,使其成为100%的工作解决方案对我来说很好。非常感谢你。有关信息,我在OpenSuse(不知道这是否会使事情不同于Windows或Mac系统)。
我正在运行的列表包含NFL网站上玩家的网页。一个例子是http://www.nfl.com/players/profile?id=00-0019290