hello, I am trying to retrieve quotes from into my database, som I ve used the following code that I came across online, but it returns error 424 (object requiered)
the string s, looks like the following :
Any ideas ?
Code:
Public Sub GetYahooData()
'< VBE > Tools > References > Microsoft Scripting Runtime
Dim json As Object, re As Object, s As String, xhr As Object
Dim startDate As String, endDate As String, stock As String
Set re = CreateObject("VBScript.RegExp")
Set xhr = CreateObject("MSXML2.XMLHTTP")
stock = "DLX"
startDate = "1534809600"
endDate = "1566345600"
With xhr
.Open "GET", "https://finance.yahoo.com/quote/" & stock & "/history?period1=" & startDate & "&period2=" & endDate & "&interval=1d&filter=history&frequency=1d&_guc_consent_skip=" & GetCurrentUnix(Now()), False
.setRequestHeader "User-Agent", "Mozilla/5.0"
.send
s = .responseText
End With
s = GetJsonString(re, s)
If s = "No match" Then Exit Sub
Set json = JsonConverter.ParseJson(s) ' returns error 424 (object requiered)
For Each item In json
Debug.Print item("date")
Debug.Print item("close")
Debug.Print item("volume")
Next
end sub
the string s, looks like the following :
Code:
[{"date":1566307800,"open":45.40999984741211,"high":45.40999984741211,"low":44.66999816894531,"close":44.970001220703125,"volume":344600,"adjclose":41.86009979248047},{"date":1566221400,"open":45.880001068115234,"high":46,"low":45.380001068115234,"close":45.52000045776367,"volume":301200,"adjclose":42.3720703125},{"date":1565962200,"open":44.31999969482422,"high":45.810001373291016,"low":44.31999969482422,"close":45.220001220703125,"volume":426100,"adjclose":42.092811584472656},{"amount":0.3,"date":1565962200,"type":"DIVIDEND","data":0.3},{"date":1565875800,"open":44.130001068115234,"high":44.54999923706055,"low":43.84000015258789,"close":44.33000183105469,"volume":419700,"adjclose":40.985111236572266},{"date":1534858200,"open":59.470001220703125,"high":60.470001220703125,"low":59.119998931884766,"close":60.13999938964844,"volume":421400,"adjclose":54.53030014038086}]
Any ideas ?