I have been trying to read lap times from a website into excel so i can post the results after the race and already have done that "successfully" however the times are not displayed using the html table function so when parsing the times to excel i got something like this: msgbox test result(msg box just for testing)
Now i must build something like a table with this text/values in a spcific order like this results_table. I know how to put them all together in a cell or present them one by one in a msgbox but not how to organize them the way i need...
The website im getting times from: "https://speedhive.mylaps.com/LiveTiming/OVXRNRVR-2147485174/Active"
"SOLUTION ON EDIT V2"
Excel vba code:
Sub Get_Race_Results()
Dim request As Object
Dim response As String
Dim html As New HTMLDocument
Dim website As String
Dim times As Variant
website = "https://speedhive.mylaps.com/LiveTiming/OVXRNRVR-2147485174/Active"
Set request = CreateObject("MSXML2.XMLHTTP")
request.Open "GET", website, False
request.setRequestHeader "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"
request.send
response = StrConv(request.responseBody, vbUnicode)
html.body.innerHTML = response
times = html.getElementsByClassName("row tab-pane active scrollable").Item(0).innerText
MsgBox times
End Sub´
EDIT V1: I could do it by using this code:
Sub Get_Race_Results()
Dim request As Object
Dim response As String
Dim html As New HTMLDocument
Dim website As String
Dim times As Variant
website = "https://speedhive.mylaps.com/Sessions/6333683"
Set request = CreateObject("MSXML2.XMLHTTP")
request.Open "GET", website, False
request.setRequestHeader "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"
request.send
response = StrConv(request.responseBody, vbUnicode)
html.body.innerHTML = response
times = html.getElementsByClassName("tab-content").Item(0).innerText
Dim LookInHere As String
Dim Counter As Integer
Dim SplitCatcher As Variant
LookInHere = times
SplitCatcher = Split(LookInHere, vbLf)
'headers
Range("A1").Value = Split(LookInHere, vbLf)(0)
Range("B1").Value = Split(LookInHere, vbLf)(1)
Range("C1").Value = Split(LookInHere, vbLf)(2)
Range("D1").Value = Split(LookInHere, vbLf)(3)
Range("E1").Value = Split(LookInHere, vbLf)(4)
Range("F1").Value = Split(LookInHere, vbLf)(5)
Range("G1").Value = Split(LookInHere, vbLf)(6)
Range("H1").Value = Split(LookInHere, vbLf)(7)
Range("I1").Value = Split(LookInHere, vbLf)(8)
Range("J1").Value = Split(LookInHere, vbLf)(9)
'1line
Range("A2").Value = Split(LookInHere, vbLf)(10)
Range("B2").Value = Split(LookInHere, vbLf)(11)
'IGNORE C2 OR LEAVE IT BLANK
Range("D2").Value = Split(LookInHere, vbLf)(12)
Range("E2").Value = Split(LookInHere, vbLf)(13)
Range("F2").Value = Split(LookInHere, vbLf)(14)
Range("G2").Value = Split(LookInHere, vbLf)(15)
Range("H2").Value = Split(LookInHere, vbLf)(16)
Range("I2").Value = Split(LookInHere, vbLf)(17)
Range("J2").Value = Split(LookInHere, vbLf)(18)
'2line etc etc until end
End Sub
EDIT V2:
Sub Get_Web_Data()
Dim request As Object
Dim response As String
Dim html As New HTMLDocument
Dim website As String
Dim times As Variant
website = "https://speedhive.mylaps.com/Sessions/6333683"
Set request = CreateObject("MSXML2.XMLHTTP")
request.Open "GET", website, False
request.setRequestHeader "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"
request.send
response = StrConv(request.responseBody, vbUnicode)
html.body.innerHTML = response
times = html.getElementsByClassName("tab-content").Item(0).innerText
Dim LookInHere As String
Dim Counter As Integer
Dim SplitCatcher As Variant
LookInHere = times
SplitCatcher = Split(LookInHere, vbLf)
Dim lrow As Long
Dim col As Long
Dim i As Long
For col = 2 To 12
For lrow = 1 To 9
Worksheets("Sheet1").Cells(col, lrow).Value = Split(LookInHere, vbLf)((10) + i)
i = i + 1
Next lrow
Next col