您的位置:首页 > 移动开发 > IOS开发

iOS-获取当前网页的 url 和 title 和 html

2016-04-07 11:27 537 查看
@property (strong,nonatomic)UIWebView *webView;
@property (strong,nonatomic)NSString *currentURL;
@property (strong,nonatomic)NSString *currentTitle;
@property (strong,nonatomic)NSString *currentHTML;

-(void) webViewDidFinishLoad:(UIWebView *)webView {

[UIApplicationsharedApplication].networkActivityIndicatorVisible =NO;
self.title = [webViewstringByEvaluatingJavaScriptFromString:@"document.title"];//获取当前页面的title

self.currentURL = webView.request.URL.absoluteString;
NSLog(@"title-%@--url-%@--",self.title,self.currentURL);

NSString *lJs = @"document.documentElement.innerHTML";//获取当前网页的html
self.currentHTML = [webView stringByEvaluatingJavaScriptFromString:lJs];

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: