I've written a script in vba to parse table from any website if the html elements are not encrypted in javascript. There is a table index in my script in which inputting the right number it is possible to parse any preferable table. Any input on this will be highly appreciated.

Sub TableData()
Dim http As New MSXML2.XMLHTTP60
Dim htmldoc As New HTMLDocument
Dim htmlas As Object, htmla As Object
Dim tRow As Object, tCel As Object

x = 2
c = 1
With http
    .Open "GET", "https://fantasy.premierleague.com/player-list/", False
    htmldoc.body.innerHTML = .responseText
End With

Set htmlas = htmldoc.getElementsByTagName("table")(0) 'Changing this index number it is possible to parse any preferable table from a webpage

For Each tRow In htmlas.Rows
    For Each tCel In tRow.Cells
        Cells(x, c) = tCel.innerText
        c = c + 1
    Next tCel
    c = 1
    x = x + 1
Next tRow
End Sub

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.