VBA:使用 wininet 从网站获取源代码

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2277794/
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-11 11:20:00  来源:igfitidea点击:

VBA: Get source code from website using wininet

internet-explorervba

提问by John Jiang

So basically I have the following code:

所以基本上我有以下代码:

Dim myIE As InternetExplorer: Set myIE = New InternetExplorer
myIE.Visible = True
myIE.Navigate URL:="http://www.google.com"
While myIE.Busy
    DoEvents  'wait until IE is done loading page.
Wend

How would I be able to get the source code of the page? And it'll be nice if someone can link me to the appropriate documentation. I'm absolutely hopeless looking through MS's website.

我怎样才能获得页面的源代码?如果有人可以将我链接到适当的文档,那就太好了。我绝对绝望地浏览 MS 的网站。

Cheers.

干杯。

回答by Mitch Wheat

You can retrieve the source HTML using:

您可以使用以下方法检索源 HTML:

strHTML = myIE.Document.body.innerHTML