Search code examples
rfor-looprcurl

R: For-Loop in RCURL


I am really new to R. That is probably why my question is really newbie.

My goal is to retrieve data through an API call. However, due the quota i have to run the same URL Call several times by changing the parameter pages e.g. from 0:24 page.

I am using RCurl for the procedure. I could not find out where the for-loop has to be started to list data from the calls 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)  


Solution

  • See page 9 of RCurl reference for more details. I believe this should work. I haven't tested it myself though.

    g <- multiTextGatherer(URLs)
    cl = getCurlHandle(verbose=T)
    txt = getURL(URLs, write = g, curl = cl)