r - 从 chrome 下载数据的代码问题
问题描述
我正在尝试从这里执行代码:https ://rpubs.com/mbadros/sp500history 但我是 R 的新手。我被困在那个街区:
library(rJava)
library(RSelenium)
base_url <- 'https://www.ishares.com/us/products/239726/ishares-core-sp-500-etf'
rD <- rsDriver(port = 4839L, browser = c("chrome"), chromever="84.0.4147.30")
remDr <- rD$client
remDr$navigate(base_url)
test <- remDr$findElement(using = 'css selector', '#holdingsTabs li a[href*="All"]')
test$clickElement()
option_list <- remDr$findElement(using = 'css selector',
'#holdingsTabs #tabsAll .date-dropdown')$selectTag()
get_top_holdings <- function(x) {
option_list$elements[[x]]$clickElement()
remDr$findElement(using = 'css selector', '.holdings .icon-xls-export')$clickElement()
}
lapply(1:length(option_list$value), get_top_holdings)
我收到一个错误:
Error in option_list$elements[[x]]$clickElement(): attempt to apply non-function
试图用谷歌解决问题,但找不到解决方案。
解决方案
推荐阅读
- optimization - 我可以在非线性优化模型中的三个变量之间使用查找表而不是 5 度多项式方程吗?
- c# - 使用 Photon Unity Network(多人游戏)在 Unity 中实时同步
- python - 我如何获取熊猫中每个值的数据类型
- c# - MsBuild StartsWith 不评估条件?
- flutter - Flutter:CupertinoTabView 内 TextField 的文本工具栏(选择、剪切、复制、粘贴)不可点击
- node.js - 为具有关联的序列模型创建存根
- db2 - 使用特定字段将数据从 AS400 获取到 Excel 的最佳方法是什么?
- android - 没有旋转地图的Android LatLng Bound
- twitter - 如何通过API调用获取twitter原始头像
- c# - WebBrowser 滚动控件