Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIWebView get HTML Source

I am trying to get the HTML source of a UIWebView without re-downloading it again (a.k.a. do another download, such as [NSData dataWithContentsOfURL:(NSURL*)URL] or launching an NSURLRequest. Browsing the UIWebView header and documentation, there seems to be no way of accessing the current loaded NSData of the source. Am I missing something ?

like image 426
Alexandre Cassagne Avatar asked Nov 29 '22 04:11

Alexandre Cassagne


1 Answers

UIWebView can execute javascript code, so this can work it out.

NSString *html = [webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.outerHTML"];
like image 95
tuoxie007 Avatar answered Dec 09 '22 18:12

tuoxie007