如何在.net中检索Web浏览器控件的HTML出帧(C#) [英] How to retrieve HTML from Webbrowser control out of frames in .net (c#)

查看:87
本文介绍了如何在.net中检索Web浏览器控件的HTML出帧(C#)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我可以通过WebBrowser控件获得HTML(源代码):



的HTMLDocument HTMLDOC = webBrowser1.Document



但这只是提供了父页面的HTML代码。在情况下,网页使用了框架,它不包括框架整个页面返回的HTML代码



我怎样才能得到完整的HTML代码,包括框架 - 或者选择一个单帧并获得该帧的HTML代码?


解决方案

  HtmlWindow帧= webBrowser1。 Document.Window.Frames [0]; 

字符串str = frame.Document.Body.OuterHtml;


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?

解决方案

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

 string str = frame.Document.Body.OuterHtml;

这篇关于如何在.net中检索Web浏览器控件的HTML出帧(C#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆