On the Internet, I found a method to obtain the html content of a webpage by running a javascript script:
Get all html:
[Cpp] NSString * lJs = @ "document.doc umentElement. innerHTML ";
NSString * lJs = @ "document.doc umentElement. innerHTML ";
Obtain the webpage title:
[Cpp] NSString * lJs2 = @ "document. title ";
NSString * lJs2 = @ "document. title ";
The usage in WebView is as follows:
[Cpp] UIWebView * lWebView = [self getCurrentWebView];
NSString * lHtml1 = [lWebView stringByEvaluatingJavaScriptFromString: lJs];
NSString * lHtml2 = [lWebView stringByEvaluatingJavaScriptFromString: lJs2];
UIWebView * lWebView = [self getCurrentWebView];
NSString * lHtml1 = [lWebView stringByEvaluatingJavaScriptFromString: lJs];
NSString * lHtml2 = [lWebView stringByEvaluatingJavaScriptFromString: lJs2];
If you want to learn more about the content in webview, see:
Http://www.bkjia.com/kf/201202/120198.html
However, the above solution does not fully meet my requirements. I think it is to obtain html content in WebVIew in real time. The preceding method can only obtain html content during WebView initialization.
So he found the great stackoverflow. The solution is as follows:
Use the UIWebViewDelegate Protocol and implement the following methods in your delegate:
[Cpp] <span style = "font-size: 18px;">-(void) webViewDidFinishLoad :( UIWebView *) webView </span>
<Span style = "font-size: 18px;">-(void) webViewDidFinishLoad :( UIWebView *) webView </span>
Note: To set: www.2cto.com
[Cpp] <span style = "font-size: 18px;"> webView. delegate = self; </span>
<Span style = "font-size: 18px;"> webView. delegate = self; </span>
Reference: http://stackoverflow.com/questions/1662565/uiwebview-finished-loading-event
From the column zcl316369