从网站上提取结果

时间:2018-02-20 18:23:54

标签: excel-vba html-table html-tableextract vba excel

我试图从类似的表中提取结果:

https://data.fei.org/Result/ResultList.aspx?p=D6E828828E450E2880525ABCEE800008C1D381967CBAF718D9DE41BEBA3B9F06

我已应用以下代码,但似乎无法正常工作。关于应该使用哪些表元素的任何想法?:

Sub Macro1()
Dim IE As New InternetExplorer
Dim CompetitionLink As String
CompetitionLink = ThisWorkbook.Worksheets("Settings").Range("B2")
IE.Navigate CompetitionLink
IE.Visible = True

Rank = IE.Document.getElementsByTagName("grid sc")(0).Rows(1).Cells(2).innerText

Debug.Print Rank

End Sub

1 个答案:

答案 0 :(得分:0)

尝试该代码



    Sub Test()
        Dim ie              As New InternetExplorer
        Dim competitionLink As String
        Dim rank            As String

        competitionLink = ThisWorkbook.Worksheets("Settings").Range("B2")

        With ie
            .Visible = True
            .navigate competitionLink
            Do: DoEvents: Loop Until .readyState = 4

            rank = .document.getElementsByClassName("grid sc")(0).Rows(1).Cells(2).innerText
            Debug.Print rank
        End With
    End Sub




**您也可以获取所有表数据..看看这个链接 Scrape HTML Table