Reading HTML content from a UIWebView

前端 未结 10 2560
感动是毒
感动是毒 2020-11-22 13:47

Is it possible to read the raw HTML content of a web page that has been loaded into a UIWebView?

If not, is there another way to pull raw HTML content f

10条回答
  •  孤城傲影
    2020-11-22 14:14

    I use a swift extension like this:

    extension UIWebView {
        var htmlContent:String? {
            return self.stringByEvaluatingJavaScript(from: "document.documentElement.outerHTML")
        }
    
    }
    

提交回复
热议问题