【发布时间】:2018-05-03 15:28:43
【问题描述】:
我用这个来获取网页
Dim xhr As MSXML2.XMLHTTP60
Set xhr = New MSXML2.XMLHTTP60
On Error Resume Next
With xhr
.Open "GET", URL, False
.send
If .ReadyState = 4 And .Status = 200 Then
Set doc = New MSHTML.HTMLDocument
doc.body.innerHTML = .responseText
htmlRequestHTTP = True
Else
MsgBox "Internet Error, please check:" & vbNewLine & "Ready state: " & .ReadyState & _
vbNewLine & "HTTP request status: " & .Status
htmlRequestHTTP = False
End If
End With
但是 doc.getElementsByTagName("META") 错过了 HEAD 部分的标签。 现在 .response 已完成(我检查过),那么我该如何访问 HEAD 元素? 谢谢,
【问题讨论】:
-
responseText包含什么?如果元标记在 HTML 源代码中,doc.getElementsByTagName("META")应该可以工作。 -
.responsetext 包含我需要的所有内容,但使用 doc.body.innerHTML = .responseText,文档显示为空 HEAD
-
doc.body
标签: vba