I'm relatively new to R and web scraping, so apologies for any inherently obvious mistakes.
I'm looking to scrape a CSV file off URL 1, increment by date to URL 2, then save each CSV file.
startdate <- as.Date("2007-07-01")
enddate <- as.Date(Sys.Date())
for(startdate in enddate){ // Loop through dates on each URL
read.csv(url("http://api.foo.com/charts/data?output=csv&data=close&startdate=",startdate,"&enddate=",startdate,"&exchanges=bpi&dev=1"))
startdate = startdate + 1
startdate <- startdate[-c(1441,1442),] // Irrelevant to question at hand. Removes unwanted information auto-inserted into CSV.
write.csv(startdate[-c(1441,1442),], startdate, 'csv', row.names = FALSE)
}
The following errors are being outputted:
read.csv(url("http://api.foo.com/charts/data?output=csv&data=close&startdate=",startdate,"&enddate=",startdate,"&exchanges=bpi&dev=1"))
// Error in match.arg(method, c("default", "internal", "libcurl", "wininet")) :'arg' should be one of “default”, “internal”, “libcurl”, “wininet”
and:
write.csv(startdate[c(1441,1442),], startdate, 'csv', row.names = FALSE)
//Error in charToDate(x) : character string is not in a standard unambiguous format
Any suggestions on how to fix these errors?