无法从 VBA 捕获具有 HTML 对象的网页内容

Unable to catch web page content with an HTML object from VBA

提问人:Phil Anki 提问时间:11/10/2022 更新时间:11/11/2022 访问量:32

问:

我使用这个 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 对象是空的

JavaScript VBA XML HTML 解析

评论


答:

0赞 Phil Anki 11/11/2022 #1

我用硒和铬,它起作用了

评论

0赞 Community 11/15/2022
正如目前所写的那样,你的答案尚不清楚。请编辑以添加其他详细信息,以帮助其他人了解这如何解决所提出的问题。您可以在帮助中心找到有关如何写出好答案的更多信息。