Hallo Excel Profis,
so manche Webseite steht im Datenaustausch mit einer json
Ich habe mir überlegt, dass wenn ich gewisse Daten abrufen will, den ganzen Umstand mit Quellcode links, rechts, oben unten
mir eigentlich schenken könnte und einfach die gewünschte json abspeichere und diese in Excel dann sofort abrufe.
Klappt!
Sub datenImport()
' importiert die Daten in json und aktualisiert die Tabelle
Dim http As Object
Dim jsonResponse As String
Dim filePath As String
Dim fileNum As Integer
Set http = CreateObject("MSXML2.XMLHTTP")
Dim url As String
url = "https://api.sofascore.com/api/v1/team/3361/events/last/0"
http.Open "GET", url, False
http.send
jsonResponse = http.responseText
filePath = "C:\Users\Fred Neumann\Desktop\Neumann\SofaScore.json"
fileNum = FreeFile
Open filePath For Output As #fileNum
Print #fileNum, jsonResponse
Close #fileNum
Set http = Nothing
Range("M11").Select
Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
End Sub
Meine Frage:
In dem Script sind die Daten auf:
https://api.sofascore.com/api/v1/team/3361/events/last/0
begrenzt, es gibt allerdings noch weitere,- indem die letzte 0 erhöht wird:
https://api.sofascore.com/api/v1/team/3361/events/last/0
https://api.sofascore.com/api/v1/team/3361/events/last/1
https://api.sofascore.com/api/v1/team/3361/events/last/2
Wie bekomme ich das Makro dahin, so das in einem Rutsch 0 bis 2 gespeichert wird?
Gruss
Fred