【发布时间】:2016-11-17 08:53:23
【问题描述】:
我有一段简单的 R 代码,它从网站读取 html 数据,然后我尝试遍历页面并从每个页面获取数据。我已经多次使用这段代码并且它有效。它将每个页面的结果添加到 R 变量中,但由于某种原因在此站点上它不起作用。有什么想法吗?
library(XML)
library(RCurl)
data <- NULL
getData <- function(url) {
#For some reason cant read directly from site, need to use RCurl to get the data first
xData <- getURL(url)
table <- data.frame(readHTMLTable(xData)$'NULL')
data <- table
}
getData(url="https://steemdb.com/accounts/reputation?page=1")
【问题讨论】:
-
x steemdb.com/accounts/reputation?page=1") x 包含数据。
-
在你的函数中添加
return(data)怎么样?我不建议混合全局环境和功能环境。