我在 excel vba 中有一个获取网页源 html 的代码(如下所示)。代码工作正常,但它获取的 html 不完整。执行该行时webpageSource = oHttp.ResponseText
,变量webpageSource包含“DOCTYPE html PUBLIC ....... etc etc直到结束/html”,这就是它应该的样子。到这里为止一切都是正确的。但是下一行debug.print webpageSource
只打印了“(adsbygoogle = window.adsbygoogle || []).push({}); ...... etc 等到最后 /html” 中的一半 html” 为什么会这样?我想从返回的响应文本中找到一些字符串,但由于它不完整,我无法这样做。有人可以解释一下吗?
谢谢
Sub source()
Dim oHttp As New WinHttp.WinHttpRequest
Dim sURL As String
Dim webpageSource As String
sURL = "http://www.somewebsite.com"
oHttp.Open "GET", sURL, False
oHttp.send
webpageSource = oHttp.ResponseText
debug.print webpageSource
End Sub
编辑:我也试过 .WaitForResponse 没有帮助:(