Bonjour à tous,
Du fait de la structure de ce json (utilisation des mots clé 'data', 'time' dans les étiquettes), voici une autre manière de faire :
Sub Bourne()
Dim DataSet As Object, Elem As Object
Dim Site As String, i As Long
Dim T As Variant, Res As Variant
T = Array("2429552-0", "2450542-0", "2443065-0", "2422601-0", "2444491-0", _
"2439937-0", "2450727-0", "2428131-0", "2449919-0", "2443064-0", _
"2443706-0", "2422660-0", "2443433-0", "2438810-0", "2424301-0", _
"2431645-0", "2423094-0", "2436787-0", "2443067-0", "2444492-0", _
"2438807-0", "2429844-0", "2439935-0", "2442331-0", "2447714-0", _
"2438661-0", "2424266-0", "2431644-0", "2448992-0", "2434763-0")
ReDim Res(8, 0)
Site = "http://simple.gagnant.place.free.fr/essai.js"
Set DataSet = VBA.CallByName(oRecordSet(Site), "data", VbGet)
For i = 0 To UBound(T)
ReDim Preserve Res(8, i)
Set Elem = VBA.CallByName(DataSet, T(i), VbGet)
Res(0, i) = T(i)
Res(1, i) = Split(VBA.CallByName(Elem, "time", VbGet))(0)
Res(2, i) = Split(VBA.CallByName(Elem, "time", VbGet))(1)
Res(3, i) = Elem.hometeam
Res(4, i) = Elem.awayteam
Res(5, i) = Elem.country
Res(6, i) = VBA.CallByName(Elem.first, "1", VbGet)
Res(7, i) = VBA.CallByName(Elem.first, "X", VbGet)
Res(8, i) = VBA.CallByName(Elem.first, "2", VbGet)
Next i
T = Array("Code", "Date", "Heure", "hometeam", "awayteam", "country", "_1_", "X", "_2_")
Sheets("Feuil1").Range("A1").Resize(1, UBound(T, 1) + 1) = T
Res = Application.Transpose(Res)
Sheets("Feuil1").Range("A2").Resize(UBound(Res, 1), UBound(Res, 2)) = Res
Set Elem = Nothing
Set DataSet = Nothing
End Sub
Function oRecordSet(Ttk As String) As Object
Dim ScriptControl As Object, Html As Object, Obj As Object, S As String
Set ScriptControl = CreateObject("MSScriptControl.ScriptControl")
ScriptControl.Language = "JScript"
Set Html = CreateObject("MSXML2.XMLHTTP")
With Html
.Open "GET", Ttk, False
.send
S = .responsetext
End With
Set Obj = ScriptControl.Eval("(" & S & ")")
Set oRecordSet = Obj
Set Obj = Nothing
End Function