提问人:Phil Anki 提问时间:11/10/2022 更新时间:11/11/2022 访问量:32
无法从 VBA 捕获具有 HTML 对象的网页内容
Unable to catch web page content with an HTML object from VBA
问:
我使用这个 URL https://www.morningstar.com/stocks/xtks/1407/dividends,并且带有即将到来的股息的表格显示在我的浏览器上 我检查页面并尝试捕捉表格的内容
我尝试了以下代码:
Dim html As New htmlDocument
Dim HTTP As Object, Elem As Object, Quote As Object
Dim iTicker As Integer, nTicker As Integer, BBG_Ticker As String, DES As String, TYP As String, MKT_STATUS As String
Dim vHeader As Variant, vData As Variant, i As Integer, j As Integer, t As Integer, k As Integer, nFields As Integer, x As Integer
Dim n As Integer
Set HTTP = CreateObject("MSXML2.XMLHTTP")
ReDim vWebPxLast(0)
With HTTP
.Open "GET", URL, True
.Send
End With
While HTTP.ReadyState <> 4
DoEvents
Wend
html.Body.innerHTML = HTTP.responseText
Crash HTTP.responseText
If HTTP.Status = 200 Then
Set Elem = html.getElementsByClassName("dividends-recent")
但 Elem 对象是空的
答:
评论