Swift Retrieve HTML data from Webview
问题 I am trying to obtain the data within the header of a web page that is being displayed in a UIWebView. How do I get the raw (unformatted) HTML string from the UIWebView? Also, I'm using iOS 9. My question is similar to Reading HTML content from a UIWebView , but this post is from 6 years ago. 回答1: From the top answer on the question you linked: NSString *html = [yourWebView stringByEvaluatingJavaScriptFromString: @"document.body.innerHTML"]; would translate into Swift: let html = yourWebView