I have a WKWebView in my project which does some operations, after clicking submit inWKWebView it displays JSON data in javaScript that I need to pars in my code.
Swift 5.1 examples:
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
print("redirect didFinish")
print(webView)
webView.evaluateJavaScript("document.documentElement.outerHTML.toString()",
completionHandler: { (html: Any?, error: Error?) in
print(html as Any)
})
}
You can get source code of your UIWebViewpage.
func webView(webView: WKWebView, didFinishNavigation navigation: WKNavigation!) {
webView.evaluateJavaScript("document.getElementsByTagName('html')[0].innerHTML") { innerHTML, error in
print(innerHTML!)
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With