ок, работает при использовании с rselenium
:
library(XML)
library(RCurl)
library(rlist)
library(RSelenium)
remDr <- remoteDriver(remoteServerAddr = "192.168.99.100", port = 4445L)
remDr$open()
remDr$navigate("http://www.cmegroup.com/trading/energy/crude-oil/west-texas-intermediate-wti-crude-oil-calendar-swap-futures_quotes_settlements_futures.html")
remDr$getTitle()
[[1]]
[1] "WTI Financial Futures Settlements - CME Group"
s = unlist(remDr$getPageSource())
tables <- readHTMLTable(s)
tables <- list.clean(tables, fun = is.null, recursive = FALSE)
n.rows <- unlist(lapply(tables, function(t) dim(t)[1]))
tables[[which.max(n.rows)]]
результат head(tables[[which.max(n.rows)]])
:
Month Open High Low Last Change Settle Estimated Volume Prior Day Open Interest
1 MAY 18 - - - - -.41 70.24 249 12,547
2 JUN 18 - - - - -.62 70.61 948 11,406
3 JLY 18 - - - - -.58 70.34 26 9,203
4 AUG 18 - - - - -.52 69.94 26 8,642
5 SEP 18 - - - - -.45 69.53 26 8,627
6 OCT 18 - - - - -.42 69.11 38 8,360
как просто настроить rselenium?
https://ropensci.github.io/RSelenium/articles/RSelenium-docker.html
при установке rselenium
и зависимостей используйте devtools
, так как некоторые пакеты отсутствуют в CRAN:
devtools::install_github("ropensci/RSelenium")
devtools::install_github("johndharrison/wdman")
devtools::install_github("johndharrison/binman")