如何使用“createDocumentFromUrl()”从vba中直接从网页获取“HTMLDocument”?我尝试了很多工作以在其中找到任何文档,但未能发现。希望有人伸出援手来实现这一点。提前致谢。无法使用createDocumentFromUrl获取html元素
这里是我到目前为止这肯定是不对的尝试:
Sub HtmlScraper()
Dim odoc As Object
Set odoc = New HTMLDocument
odoc.Open createDocumentFromUrl("http://www.stackoverflow.com", "null")
MsgBox odoc.body.innerHTML
End Sub
我想这样很好,但没有运气:
Sub htmlparser()
Dim odoc As HTMLDocument, hdoc As HTMLDocument
Set odoc = New HTMLDocument
Set hdoc = New HTMLDocument
Set hdoc = odoc.createDocumentFromUrl("http://www.stackoverflow.com", Null, False)
MsgBox hdoc.body.outerHTML
End Sub
还检查新文档的'.readystate'和'.busy'属性。 –