VBA - Get contents of HTML Table

dotmannn

New Member
Joined
Mar 26, 2014
Messages
16
Hi,

I've spent the last couple of days searching to try and find a solution to this but really having trouble getting my code to work. I'm trying to pull in the below value:

fHhimPU.jpg


Its the number 4 that I need to pull in. I've managed to get the code working to log into the website and navigate to this page but having real trouble pulling in the correct rank (4 in this case)

I've gotten this far but it fails on this line... I cant really go any further than this:

Rank = ie.Document.getElementById("app_rankings")

I'm assuming I need to work my way through the div tags using getElementbyClassName or getElementbyID

app_rankings->complex-table-region-main etc...

Any ideas?

Code:
Sub Test()    Dim ie As Object
    Dim Rank As Object
    Set ie = CreateObject("InternetExplorer.application")
    ie.Visible = True
    ie.Navigate ("http://appannie.com/account/logout/")
    Do
        If ie.ReadyState = 4 Then
            Exit Do
        Else
        End If
    Loop
    
    ie.Navigate ("http://appannie.com/account/login/")
    Do
        If ie.ReadyState = 4 Then
            Exit Do
        Else
        End If
    Loop
    ie.Document.getElementById("username").Value = "*****"
    ie.Document.getElementById("password").Value = "*****"
    ie.Document.getElementById("login_submit_button").Click
    prevCOB = Format(Application.WorksheetFunction.WorkDay(Date, -1), "YYYY-MM-DD")
    
    Do
        If ie.ReadyState = 4 Then
            Exit Do
        Else
        End If
    Loop
    ie.Navigate ("http://www.appannie.com/apps/ios/app/465712788/app-ranking/#device=iphone&daily=" & prevCOB & "&type=ranks")
    
    
[B]    Rank = ie.Document.getElementById("app_rankings")[/B]
    Rank = Rank.getElementsByClassName("complex-table")
End Sub
 
Last edited:
Third cell in the second row of the nth table (can't tell which table index), so:
Code:
IE.document.getElementsByTagName("TABLE")(n).rows(1).cells(2).innerText
Try 0, 1, 2, etc. for n.
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top