Webbrowser与HtmlAgility的结合

神,这么复杂的标题~~

            HtmlAgilityPack.HtmlDocument htmlDocument = new HtmlAgilityPack.HtmlDocument();

            mshtml.HTMLDocument htmldocument = (mshtml.HTMLDocument)webBrowser.Document.DomDocument;

            string temp = htmldocument.documentElement.outerHTML;

            byte[] buffer = Encoding.GetEncoding(webBrowser.Document.Encoding).GetBytes(temp);

            MemoryStream ms = new MemoryStream(buffer);

            htmlDocument.Load(ms, Encoding.GetEncoding(webBrowser.Document.Encoding));

 

你可能感兴趣的:(WebBrowser)