Firstly you need to identify the URL of the resource you wish to download over HTTP. After having a look at the HTML I found that this is the actual URL for the CSV:
http://www.google.com/trends/trendsReport?hl=en-US&cat=0-14&date=today%207-d&cmpt=q&content=1&export=1
You will need to experiment and see how this is formatted.
Now that you have the URL you need to download it using HTTP. You can either use the SDK's request system or a far superior library such as ASIHTTPRequest
or AFNetworking
. I would use AFNetworking
since the former has now been discontinued by its developer.
https://github.com/AFNetworking/AFNetworking
NSURL *url = [NSURL URLWithString:@"http://domain.com/theFileYouWant.csv"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc]initWithRequest:request];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"success: %@", operation.responseString);
}
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"error: %@", operation.responseString);
}
];
[operation start];
This is some sample code to download a CSV file with AFNetworking (I haven't tested this). Once you have downloaded the file you can perform whatever operations you wanted to on it.
Hope this helps!