Rscript -e 't1<-as.integer(as.POSIXct("2010-01-01",tz="UTC"));t2<-as.integer(as.POSIXct("2022-07-01",tz="UTC"));gety<-function(sym){u<-paste0("https://query1.finance.yahoo.com/v8/finance/chart/",URLencode(sym,reserved=T),"?period1=",t1,"&period2=",t2,"&interval=1d");s<-paste(readLines(u,warn=F),collapse="");tk<-'"timestamp":[';p<-regexpr(tk,s,fixed=T);z<-substring(s,p+nchar(tk));tt<-as.numeric(strsplit(substr(z,1,regexpr("]",z,fixed=T)-1),",",fixed=T)[[1]]);tk<-'"close":[';p<-regexpr(tk,s,fixed=T);z<-substring(s,p+nchar(tk));cc<-as.numeric(strsplit(substr(z,1,regexpr("]",z,fixed=T)-1),",",fixed=T)[[1]]);cat(length(tt),length(cc),"\n",head(cc,2),tail(cc,2));};gety("^GSPC")'