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

本文转载至 http://www.th7.cn/Program/IOS/201310/156916.shtml

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

      

}  

posted @ 2015-03-03 17:21  天牛  阅读(1033)  评论(0编辑  收藏  举报