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.
From the top answer on the question you linked:
would translate into Swift:
stringByEvaluatingJavaScriptFromString
returns a optional, so you'd probably want to later use anif let
statement:Don't forgot get the html when the page render finished, if you got html too early, the result will be empty.
swift 4: