vb.net 如何从 webbrowser.document 获取整个 html

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17872883/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 14:24:53  来源:igfitidea点击:

How to get the whole html from webbrowser.document

htmlvb.net

提问by Danu Rush

If dw1() return webbrowser.document I know I can do:

如果 dw1() 返回 webbrowser.document 我知道我可以这样做:

dw1.body.outerhtml

to get the outerhtml of the body. That's it, body, header, etc.

获取body的outerhtml。就是这样,正文,标题等。

What about if I want to get the html of the whole document?

如果我想获取整个文档的 html 怎么办?

回答by John Koerner

If you have access to the webbrowser control, you can use the DocumentTextproperty:

如果您有权访问 webbrowser 控件,则可以使用该DocumentText属性:

Private Sub WebBrowser1_DocumentCompleted(sender As Object, e As WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
    MessageBox.Show(WebBrowser1.DocumentText) 
End Sub