Save WebBrowser Control Content to HTML

烂漫一生 提交于 2019-12-07 09:18:23

问题


I have a WebBrowser Control and have called the Navigate(url) function of it for a given file. Then I have manipulated the DOM tree by giving new Id's to some of the tags.

Now I want to save the result in an HTML file. I have tried to use the webBrowser.DocumentStream, but it seems that this stream won't change after manipulating the DOM tree.

Please keep in mind that the encoding in WebBrowser.Document.Encoding must be used to encode the result.


回答1:


Like this:

File.WriteAllText(path, browser.Document.Body.Parent.OuterHtml, Encoding.GetEncoding(browser.Document.Encoding));


来源:https://stackoverflow.com/questions/2976701/save-webbrowser-control-content-to-html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!