R:RCURL 中的 For 循环
R: For-Loop in RCURL
我真的是 R 的新手。这可能就是为什么我的问题真的是新手的原因。
我的目标是通过 API 调用检索数据。但是,由于配额,我必须 运行 相同的 URL 通过更改参数页面调用多次,例如来自 0:24 页。
我在程序中使用 RCurl。我找不到必须从何处开始 for 循环以列出来自调用 0: 24:
的数据
URL <- paste(base.html.string,
'/', ID,
'/data/', Action,
'?queryId=', Query,
'&startDate=', startDate,
'&search=', SearchQuery,
'&endDate=', endDate,
'&pageSize=', results,
'&page=',pages,
'&access_token=', Access_token,
'&orderBy=date',
sep = '')
Content <- getURLContent(URL)
有关详细信息,请参阅 page 9 of RCurl reference。我相信这应该有效。不过我还没有亲自测试过。
g <- multiTextGatherer(URLs)
cl = getCurlHandle(verbose=T)
txt = getURL(URLs, write = g, curl = cl)
lapply(0:24,function (i)paste(base.html.string, '/', ID, '/data/', Action, '?queryId=', Query, ' &startDate=', startDate, '&search=', SearchQuery, '&endDate=', endDate, '&pageSize=', 结果, '&page=',i, '&access_token=', Access_token, '&orderBy=date', sep = '')%>% getUrlContent)
但这不是做你想做的最好的方法。我认为对于循环中的 "newbie" api 调用相当复杂。您也可以将解析器传递到 RHS 链中
我真的是 R 的新手。这可能就是为什么我的问题真的是新手的原因。
我的目标是通过 API 调用检索数据。但是,由于配额,我必须 运行 相同的 URL 通过更改参数页面调用多次,例如来自 0:24 页。
我在程序中使用 RCurl。我找不到必须从何处开始 for 循环以列出来自调用 0: 24:
的数据 URL <- paste(base.html.string,
'/', ID,
'/data/', Action,
'?queryId=', Query,
'&startDate=', startDate,
'&search=', SearchQuery,
'&endDate=', endDate,
'&pageSize=', results,
'&page=',pages,
'&access_token=', Access_token,
'&orderBy=date',
sep = '')
Content <- getURLContent(URL)
有关详细信息,请参阅 page 9 of RCurl reference。我相信这应该有效。不过我还没有亲自测试过。
g <- multiTextGatherer(URLs)
cl = getCurlHandle(verbose=T)
txt = getURL(URLs, write = g, curl = cl)
lapply(0:24,function (i)paste(base.html.string, '/', ID, '/data/', Action, '?queryId=', Query, ' &startDate=', startDate, '&search=', SearchQuery, '&endDate=', endDate, '&pageSize=', 结果, '&page=',i, '&access_token=', Access_token, '&orderBy=date', sep = '')%>% getUrlContent)
但这不是做你想做的最好的方法。我认为对于循环中的 "newbie" api 调用相当复杂。您也可以将解析器传递到 RHS 链中