I want to pull some HTML content from a website using a UIWebView
. Below is the code. I know that using [webView stringByEvaluatingJavaScriptFromString:@"document.body.innerHTML"];
but the above is not working.
Could you guys please help me with which part I exactly have to insert the code to work? If any changes or modifications need to be done in the code. I'd be so grateful. I'm a newbie. The below code just shows the HTML content scrambled.
- (void)viewDidLoad {
[super viewDidLoad];
NSString *urlAddress=@"http://www.firesky.com/";
NSURL *url = [NSURL URLWithString:urlAddress];
//NSURLRequest *requestObj=[NSURLRequest requestWithURL:url];
NSError *error;
NSString *googlepage = [NSString stringWithContentsOfURL:url
encoding:NSASCIIStringEncoding error:&error];
//[webView stringByEvaluatingJavaScriptFromString:@"document.body.innerHTML"];
[webView loadHTMLString:googlepage baseURL:nil];
[webVi开发者_Python百科ew release];
}
Load the page into the
UIWebView
as normal:[webView loadRequest:
[NSURLRequest requestWithURL:
[NSURL URLWithString:@"http://google.com"]]];When the page is loaded, run your JavaScript.
I used FireBug to debug my scripts in browser before I embed them in the app. It makes the workflow a little more efficient.
精彩评论