当尝试运行RSelenium示例尝试执行某些网页抓取时,我在尝试打开服务器时收到以下错误消息...我不确定问题是什么......
library(RSelenium)
startServer()
# use default server initialisation values
remDr <- remoteDriver$new()
# send request to server to initialise session
remDr$open()
[1] "Connecting to remote server"
$message
[1] "GET /session/\nBuild info: version: '2.42.0', revision: '5e82430', time: '2014-05-22 20:18:07'\nSystem info: host: 'xxxxx-PC', ip: 'xx.xxx.xx.xx', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.7.0_60'\nDriver info: driver.version: unknown"
$localizedMessage
[1] "GET /session/\nBuild info: version: '2.42.0', revision: '5e82430', time: '2014-05-22 20:18:07'\nSystem info: host: 'xxxx-PC', ip: 'xx.xxx.xx.xx', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.7.0_60'\nDriver info: driver.version: unknown"
$suppressed
list()
$cause
NULL
$systemInformation
[1] "System info: host: 'xxxxx-PC', ip: 'xx.xx.xx.xx', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.7.0_60'"
$supportUrl
NULL
$class
[1] "org.openqa.selenium.UnsupportedCommandException"
$additionalInformation
[1] "\nDriver info: driver.version: unknown"
$hCode
[1] 142976762
然后有一些stackTrace信息,所有这些都是NULL
有关如何解决此问题的任何想法?
同样在尝试运行演示时,我遇到了以下问题...(但请考虑因为RSelenium::startServer()
没有先运行)
> demo(selExecJSexample)
demo(selExecJSexample)
---- ~~~~~~~~~~~~~~~~
Type <Return> to start :
> # see http://stackoverflow.com/questions/22121006/how-to-scrape-this-squawka-page/22127054#22127054
> # RSelenium::startServer() # if needed
> require(RSelenium)
> remDr <- remoteDriver()
> remDr$open()
[1] "Connecting to remote server"
Error in function (type, msg, asError = TRUE) : couldn't connect to host
答案 0 :(得分:1)
这是一个问题,selenium发布周期与firefox发布周期略有不同步。 http://selenium-release.storage.googleapis.com/index.html现在包含更新的Selenium Server(当前版本为2.43.0)。使用RSelenium::checkForServer
运行update = TRUE
将在本地更新Selenium Server,并且最新的firefox应该正常运行:
> library(RSelenium)
> checkForServer(update = TRUE)
[1] "DOWNLOADING STANDALONE SELENIUM SERVER. THIS MAY TAKE SEVERAL MINUTES"
trying URL 'http://selenium-release.storage.googleapis.com/2.43/selenium-server-standalone-2.43.0.jar'
Content type 'application/x-java-archive' length 34932130 bytes (33.3 Mb)
opened URL
downloaded 33.3 Mb
> remDr <- remoteDriver()
> startServer()
> remDr$open()
[1] "Connecting to remote server"
$platform
[1] "WINDOWS"
$acceptSslCerts
[1] TRUE
$javascriptEnabled
[1] TRUE
$browserName
[1] "firefox"
$rotatable
[1] FALSE
$locationContextEnabled
[1] TRUE
$webdriver.remote.sessionid
[1] "a2eee1ff-d9fd-41ce-ac0e-e11ce24cb516"
$version
[1] "32.0"
$cssSelectorsEnabled
[1] TRUE
$databaseEnabled
[1] TRUE
$handlesAlerts
[1] TRUE
$webStorageEnabled
[1] TRUE
$nativeEvents
[1] TRUE
$applicationCacheEnabled
[1] TRUE
$takesScreenshot
[1] TRUE
$id
[1] "a2eee1ff-d9fd-41ce-ac0e-e11ce24cb516"
运行remDr$getStatus()
应该显示所有内容都是最新的:
> remDr$getStatus()
$os
$os$arch
[1] "amd64"
$os$name
[1] "Windows 8.1"
$os$version
[1] "6.3"
$java
$java$version
[1] "1.7.0_67"
$build
$build$revision
[1] "597b76b"
$build$time
[1] "2014-09-09 20:52:14"
$build$version
[1] "2.43.0"