如何从 .net 中的框架外的 Webbrowser 控件检索 HTML (c#)

发布于 2024-08-06 17:43:02 字数 219 浏览 1 评论 0原文

我知道我可以通过以下方式获取 Webbrowser 控件的 HTML(源代码):

HtmlDocument htmldoc = webBrowser1.Document

但这仅提供“父页面”的 html 代码。如果网页使用框架,则不会返回包括框架在内的整个页面的 html 代码。

如何获取包含框架的完整 HTML 代码 - 或者选择单个框架并获取该框架的 html 代码?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

埖埖迣鎅 2024-08-13 17:43:02
 HtmlWindow frame = webBrowser1.Document.Window.Frames[0];

 string str = frame.Document.Body.OuterHtml;
 HtmlWindow frame = webBrowser1.Document.Window.Frames[0];

 string str = frame.Document.Body.OuterHtml;
原来分手还会想你 2024-08-13 17:43:02

我最好的选择是:

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

my best option was:

WB1.Document.Window.Frames[0].Document.GetElementsByTagName("HTML")[0].OuterHtml
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文