ios - 怎么查看uiwebview, 加载网页 后的html源码?
大家讲道理
大家讲道理 2017-04-18 09:15:52
0
2
254

我用uiwebview 加载了一个url连接, 我怎么能查看uiwebview加载后的生成的html源码, 我想查看里面的元素结构

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(2)
Peter_Zhu

In the webViewDidFinishLoad proxy method

    NSString *jsToGetHTMLSource = @"document.documentElement.innerHTML";
        
        if (SYSTEM_VERSION_LESS_THAN(@"8.0")) {
            NSString *AllHtml = [self.testWebView stringByEvaluatingJavaScriptFromString:jsToGetHTMLSource];

            [self analysisWebViewSourceCode:AllHtml];
        }else
        {
            [self.wkWebView evaluateJavaScript:jsToGetHTMLSource completionHandler:^(id _Nullable string, NSError * _Nullable error) {
                [self analysisWebViewSourceCode:string];
            }];

This way you can get the source code of html.

洪涛

Obviously use Safari The developer menu of the browser to do this...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template