ios webview 獲取 網頁的URL、title和HTML
@property (strong,nonatomic)UIWebView *webView;
@property (strong,nonatomic)NSString *currentURL;
@property (strong,nonatomic)NSString *currentTitle;
@property (strong,nonatomic)NSString *currentHTML;
[objc] view plaincopy
---------------------------------
[objc]
[objc]
-(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];
}