Save WebBrowser Control Content in HTML

I have a WebBrowser control and the Navigate (url) function is called for this file. Then I processed the DOM tree by specifying a new identifier for some of the tags.

Now I want to save the result in an HTML file. I tried using webBrowser.DocumentStream, but it seems that this stream will not change after manipulating the DOM tree.

Please keep in mind that to encode the result you must use the encoding in WebBrowser.Document.Encoding.

+3
source share
1 answer

Like this:

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

Source: https://habr.com/ru/post/1748572/


All Articles