hrincong
hrincong

Reputation: 21

How to download a web page data in Objective-C and wait until JavaScript is executed?

I try some like that:

NSString *url = @"http://www.example.com";
NSURL *urlRequest = [NSURL URLWithString:url];
NSError *err = nil;

NSString *html = [NSString stringWithContentsOfURL:urlrequest encoding:NSUTF8StringEncoding error:&err];

This returns the html to me perfectly, but it does not return the data that is created from JavaScript, for example graphics and stuff.

Upvotes: 0

Views: 198

Answers (1)

Jon Taylor
Jon Taylor

Reputation: 7905

Javascript is executed by the browser not the server. When you make a request to the server for a document it processes that request and returns the html/js/css relevant to that page. The browser then executes the javascript locally to do whatever it is it is meant to do, i.e. create images, load ajax data etc.

Your C code is pulling the raw html/js from the server. This is why you are not getting the images etc you expected.

Upvotes: 1

Related Questions