// Download historical price data from Yahoo
function main()
{
int id = http_post("http://ichart.finance.yahoo.com/table.csv?s=AAPL&c=1980",0);
if(!id) return;
while(!http_status(id))
if(!wait(100)) return; // wait for the server to reply
int length = http_status(id);
if(length > 0) { //transfer successful?
string content = (string)malloc(length);
http_result(id,content,length); // store price data in large string
file_write("History\AAPL.csv",content,length);
free(content); // release the string
}
http_free(id); //always clean up the id!
}