【发布时间】:2018-06-12 16:12:24
【问题描述】:
我正在尝试使用 rvest 从ASX 中获取期权价格,我希望有人帮助我管理我的代码。我想管道并最终得到一个数据框。
上面链接的页面有两个表格,第一个表格包含股价信息,第二个表格包含所有选项。当我运行以下代码时,我得到第二个表的数据框:
html <- read_html("http://www.asx.com.au/asx/markets/optionPrices.do?by=underlyingCode&underlyingCode=ANZ&expiryDate=&optionType=B")
nodes <- html_nodes(html, "table.options")
df <- html_table(nodes)[[2]]
但是,当我尝试使用以下内容管道相同的代码时:
html <- read_html("http://www.asx.com.au/asx/markets/optionPrices.do?by=underlyingCode&underlyingCode=ANZ&expiryDate=&optionType=B")
html %>%
html_nodes("table.options") %>%
html_table()[[2]]
我收到一个错误,读取“UseMethod("html_table") 中的错误: 没有适用于 'html_table' 的方法应用于“NULL”类的对象'
谁能告诉我我做错了什么?
【问题讨论】:
-
另见here
-
至少有礼貌地告知潜在的回答者,您愿意为您的经济利益让他们面临民事和刑事处罚的风险。 asx.com.au/about/terms-use.htm
标签: r web-scraping rvest piping