Power query Masters scoreboard

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
I could not connect to that page using Power Query. Would you accept a VBA solution?
 
Upvote 0
I couldn't connect either. I wrote a VBA work around that works (below). Couldn't get a sub to work without having to actually open IE. So interested if you have any suggestions on improving what I wrote. Power Query would have been nice because I can set it up to auto refresh every so often. Obviously not needed for the 2020 tournament scores but will be using it in 2021 as the tournament is live.

This works:

Sub ExtractTable()
Dim IE As New SHDocVw.InternetExplorer
IE.Visible = True
IE.navigate "https://www.masters.com/en_US/scores/"
Dim HTMLDoc As MSHTML.HTMLDocument
Dim Positions As MSHTML.IHTMLElementCollection
Dim Position As MSHTML.IHTMLElement

Dim a(1 To 1000, 1 To 10)
Do While IE.readyState <> READYSTATE_COMPLETE
DoEvents
Loop

Set HTMLDoc = IE.document

Set Positions = HTMLDoc.getElementsByClassName("data")

t = Timer
Do While Timer - t < 5 And Positions.Length = 0
DoEvents
Loop
Debug.Print Timer - t

j = 1
ii = 1
newline = 10
For i = 0 To Positions.Length - 1
k = k + 1
a(ii, j) = Positions(i).innerText
If a(ii, j) = "MC" Then newline = 8
j = j + 1
If (i + 1) Mod newline = 0 Then
j = 1
ii = ii + 1
End If
Next
ActiveSheet.Range(Cells(1, 1), Cells(i, 10)) = a
IE.Quit
Set IE = Nothing
End Sub


This one fails:

Sub ExtractTable1()
Dim XMLPage As New MSXML2.XMLHTTP60

'IE.Visible = True
'IE.navigate "https://www.masters.com/en_US/scores/"
Dim HTMLDoc As New MSHTML.HTMLDocument
Dim Positions As MSHTML.IHTMLElementCollection
Dim Position As MSHTML.IHTMLElement
Dim PlayerNames As MSHTML.IHTMLElementCollection
Dim PlayerName As MSHTML.IHTMLElement
Dim AmountUnders As MSHTML.IHTMLElementCollection
Dim AmountUnder As MSHTML.IHTMLElement
Dim a(1 To 1000, 1 To 10)
XMLPage.Open "GET", "https://www.masters.com/en_US/scores/", False
XMLPage.send
HTMLDoc.body.innerHTML = XMLPage.responseText

Set Positions = HTMLDoc.getElementsByClassName("data")
Set PlayerNames = HTMLDoc.getElementsByClassName("data ")
Set AmountUnders = HTMLDoc.getElementsByClassName("data under")
t = Timer
Do While Timer - t < 5 And Positions.Length = 0
DoEvents
Loop
Stop
j = 1
ii = 1
For i = 0 To Positions.Length - 1
If (i + 1) Mod 10 = 0 Then
j = 1
ii = ii + 1
End If
k = k + 1
a(ii, j) = Positions(i).innerText
j = j + 1
Next
ActiveSheet.Range(Cells(1, 1), Cells(i, 10)) = a
Stop
Set IE = Nothing
End Sub
 
Upvote 0
I don't think that VBA will work either because they are using REACT to render the info on the page.

It works with Power Query on a different website though.

Book1 (version 1).xlsb
ABCDEFGHIJ
1POSNAMETOTALTHRUTODAYR1R2R3R4TOTAL_1
21Dustin Johnson-20F-465706568268
3T2Cameron Smith-15F-367686969273
4T2Sungjae Im-15F-366706869273
54Justin Thomas-12F-266697170276
6T5Rory McIlroy-11F-375666769277
7T5Dylan Frittelli-11FE65736772277
8T7C.T. Pan-10F-470667468278
9T7Brooks Koepka-10F-270696970278
10T7Jon Rahm-10F-169667271278
11T10Webb Simpson-9F-467737168279
Sheet7


Power Query:
let
    Source = Web.Page(Web.Contents("https://www.augusta.com/masters/leaderboard")),
    Data0 = Source{0}[Data],
    RemovedTopRows = Table.Skip(Data0,2),
    PromoteHeaders = Table.PromoteHeaders(RemovedTopRows, [PromoteAllScalars=true]),
    Types = Table.TransformColumnTypes(PromoteHeaders,{{"POS", type text}, {"NAME", type text}, {"TOTAL", type text}, {"THRU", type text}, {"TODAY", type text}, {"R1", Int64.Type}, {"R2", Int64.Type}, {"R3", Int64.Type}, {"R4", Int64.Type}, {"TOTAL_1", Int64.Type}}),
    KeptFirstRows = Table.FirstN(Types,10)
in
    KeptFirstRows
 
Upvote 0
Solution
I don't think that VBA will work either because they are using REACT to render the info on the page.

For the record, there is working VBA code at the third post.
 
Upvote 0

Forum statistics

Threads
1,223,744
Messages
6,174,252
Members
452,553
Latest member
red83

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