UIWebView gets HTML source

I am trying to get the HTML source code of a UIWebView without reloading it (for example, doing another loading, for example [NSData dataWithContentsOfURL:(NSURL*)URL] ) or running NSURLRequest. Looking through the title and documentation of the UIWebView, there seems to be no way to access the currently loaded NSData source. Did I miss something?

+4
source share
2 answers

The reverse should do what you want. That is, load the URL into the NSData object and then load the UIWebView from this object using – loadData:MIMEType:textEncodingName:baseURL:

+1
source

UIWebView can execute javascript code, so this may work.

 NSString *html = [webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.outerHTML"]; 
+24
source

Source: https://habr.com/ru/post/1312854/


All Articles