How to retrieve HTML from Webbrowser control out o

2020-04-14 12:00发布

问题:

I know that I can get the HTML (source code) of a Webbrowser control via:

HtmlDocument htmldoc = webBrowser1.Document

But this does only provide the html code of the "parent page". In case the webpage uses frames, it does not return the html code for the whole page including frames.

How can I get the complete HTML code including frames - or select a single frame and get the html code of that frame?

回答1:

 HtmlWindow frame = webBrowser1.Document.Window.Frames[0];

 string str = frame.Document.Body.OuterHtml;


回答2:

my best option was:

WB1.Document.Window.Frames[0].Document.GetElementsByTagName("HTML")[0].OuterHtml