Get the final rendered HTML code after Javascript and ect

前端 未结 1 1337
既然无缘
既然无缘 2021-01-25 10:05

I\'m using C#, and I\'ve been struggling for a few days for grabbing the final rendered HTML from an URL.

I\'ve tried using several browser engines, Awesomium, WebBrows

相关标签:
1条回答
  • 2021-01-25 10:50

    What I do is roughly the following (using the WebBrowser WinForms control):

    public static string GetDomSource(WebBrowser wb)
    {
        var dd = wb.Document.DomDocument as IHTMLDocument2;
        return dd.body.parentElement.outerHTML;
    }
    

    (Though I don't know whether you already tried this or whether you are using WinForms at all).

    To introduce the IHTMLDocument2 interface, I've add a reference to the "Microsoft.mshtml" assembly.

    0 讨论(0)
提交回复
热议问题