Hello Everyone,

I am trying to download data from multiple websites using API key.
The  code to download from one URL is given below.

I have a list of multiple URLs' where the suffix URL 'c' keeps changing.

I would appreciate any help on how i can modify the code below that will
allow
 me to read multiple URLs and save the data from each URL as separate
csv file.

thanks,
bhaskar


#-----------------------------------------------------------------------
library(rjson)
setwd(Input)

base_url <- "abcd"         # This remains constant

b <-  "api_key"            # the api key - this remains constant

c <-  "series_id=1"        # Only this suffix URL changes.  I have a list
of multiple such URL's with different series ids.


full_url = paste0(base_url,
                  b,
                  c)


d3 <- lapply(fromJSON(file=full_url)[[2]], function(x) c(x["data"]))
d3 <- do.call(rbind, d3)

b <- as.data.frame(unlist(d3))
write.csv(b)

#-----------------------------------------------------------------------

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to