excelhtml-tablehtml-tableextractvba

Results extraction from website


I was trying to extract results from similar table:

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

I have applied following code but doesn't seem to work. Any ideas on what table elements should be used?:

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

Solution

  • Try that code

        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

    ** You can also grab all the table data .. Have a look at this link Scrape HTML Table