search

Home  >  Q&A  >  body text

ios - 怎么查看uiwebview, 加载网页 后的html源码?

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

大家讲道理大家讲道理2893 days ago255

reply all(2)I'll reply

  • 天蓬老师

    天蓬老师2017-04-18 09:17:52

    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.

    reply
    0
  • PHP中文网

    PHP中文网2017-04-18 09:17:52

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

    reply
    0
  • Cancelreply