开发者

objective c pulling content from website

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];
}


  1. Load the page into the UIWebView as normal:

    [webView loadRequest:
    [NSURLRequest requestWithURL:
    [NSURL URLWithString:@"http://google.com"]]];
  2. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜