做类似新闻的详情页面用到了webView 加载解析的HTML文件
#define kUrl @"http://blog.sina.com.cn/s/blog_af73e7a701019co0.html"
//加载指定的网页
NSURL *url = [NSURL URLWithString:kUrl];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[self.webView loadRequest:request];
//加载解析的HTML
[self loadWebPageWithString:@"http://c.3g.163.com/nc/article/AF7E8D3S00964LQ9/full.html"];
//解析HTML
- (void)loadWebPageWithString:(NSString*)urlString
{
NSURL *url =[NSURL URLWithString:urlString];
NSURLRequest *request =[NSURLRequest requestWithURL:url];
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
NSLog(@"++++>>:%@",data);
NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
NSLog(@"dict>>>:%@",dict);
NSString *str = dict[@"AF7E8D3S00964LQ9"][@"body"];
NSLog(@">>>:%@",str);
[self.webView loadHTMLString:str baseURL:nil];
}];
}
待完善...