使用R连接Selenium服务器单机版
参考本网站的帖子,我可以创建一个webdriver。但是,我无法获得与Python相同的元素详细信息。我可以知道怎么做吗 我想刮掉每一轮的足球比赛桌使用R连接Selenium服务器单机版,r,python-2.7,selenium-webdriver,selenium-rc,R,Python 2.7,Selenium Webdriver,Selenium Rc,参考本网站的帖子,我可以创建一个webdriver。但是,我无法获得与Python相同的元素详细信息。我可以知道怎么做吗 我想刮掉每一轮的足球比赛桌 # using R library(RCurl) library(RJSONIO) library(XML) # running selenium system("java -jar selenium-server-standalone-2.35.0.jar") baseURL<-"http://localhost:4444/wd/hub/
# using R
library(RCurl)
library(RJSONIO)
library(XML)
# running selenium
system("java -jar selenium-server-standalone-2.35.0.jar")
baseURL<-"http://localhost:4444/wd/hub/"
server<-list(desiredCapabilities=list(browserName='firefox',javascriptEnabled=TRUE))
getURL(paste0(baseURL,"session"),
customrequest="POST",
httpheader=c('Content-Type'='application/json;charset=UTF-8'),
postfields=toJSON(server))
serverDetails<-fromJSON(rawToChar(getURLContent('http://localhost:4444/wd/hub/sessions',binary=TRUE)))
serverId<-serverDetails$value[[1]]$id
# navigate to 7m.cn
URL = "http://data2.7m.cn/history_Matches_Data/2009-2010/92/en/index.shtml"
getURL(paste0(baseURL,"session/",serverId,"/url"),
customrequest="POST",
httpheader=c('Content-Type'='application/json;charset=UTF-8'),
postfields=toJSON(list(url=URL)))
您可以使用该软件包(Selenium for R)。免责声明:我是开发者之一
require(relenium)
firefox <- firefoxClass$new()
firefox$get('http://data2.7m.cn/history_Matches_Data/2009-2010/92/en/index.shtml')
content <- firefox$getPageSource()
firefox$close()
require(释放)
火狐
require(relenium)
firefox <- firefoxClass$new()
firefox$get('http://data2.7m.cn/history_Matches_Data/2009-2010/92/en/index.shtml')
content <- firefox$getPageSource()
firefox$close()