Hello,
my problem is i get an empy json string. I want to get data of Tradingview.com. I find and read out all nessesary infos for a post request (i think nothing overseen) with network analysing tool of firefox. URL and post data in following source code. B.t.w. with my way is only a single request possible, but i want to get the values (e.g.) every second, is it possible? I tried different ways, i tried with 'Sub JobDone' and 'wait for (job)', tried 1 and 2 HttpJobs, tried json as direct string and with JSONGenerator and i set header, but nothing works. I get no cookie data, is it maybe important in headers..? Whole Project (small) uploaded.
Tried same project with python, same empty json string.
(Unused subs here deleted for short view)
The JSON String is
The response should be like
Did i oversee something important or is there a much easier way?
Thanks for replies and your time.
my problem is i get an empy json string. I want to get data of Tradingview.com. I find and read out all nessesary infos for a post request (i think nothing overseen) with network analysing tool of firefox. URL and post data in following source code. B.t.w. with my way is only a single request possible, but i want to get the values (e.g.) every second, is it possible? I tried different ways, i tried with 'Sub JobDone' and 'wait for (job)', tried 1 and 2 HttpJobs, tried json as direct string and with JSONGenerator and i set header, but nothing works. I get no cookie data, is it maybe important in headers..? Whole Project (small) uploaded.
Tried same project with python, same empty json string.
(Unused subs here deleted for short view)
Service:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim start,check As HttpJob
End Sub
Sub Service_Start (StartingIntent As Intent)
Service.StopAutomaticForeground 'Starter service can start in the foreground state in some edge cases.
startReq
End Sub
Sub startReq()
start.Initialize("",Me)
start.Download("https://tradingview.com/symbols/USOIL/technicals/")
start.GetRequest.SetHeader("Accept","text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8")
start.GetRequest.SetContentEncoding("gzip, deflate, br")
start.GetRequest.SetHeader("Accept-Language", "de,en-US;q=0.7,en;q=0.3")
start.GetRequest.SetHeader("Cache-Control","no-cache")
start.GetRequest.SetHeader("Connection","keep-alive")
start.GetRequest.SetHeader("DNT","1")
start.GetRequest.SetHeader("Host", "tradingview.com")
start.GetRequest.SetHeader("Upgrade-Insecure-Requests", "1")
start.GetRequest.SetHeader("Pragma", "no-cache")
start.GetRequest.SetHeader("User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:77.0) Gecko/20100101 Firefox/77.0")
wait for (start) JobDone(job As HttpJob)
If job.success Then
getData()
Else
Log("Error:")
Log(job.ErrorMessage)
End If
job.release
End Sub
Sub getData()
Dim fx As String = "FX:USOIL"
Dim vals As Map
vals.Initialize
Dim symbols As Map
symbols.Initialize
Dim tickers As List
tickers.Initialize
tickers.Add(fx)
Dim query As Map
query.Initialize
Dim types As List
types.Initialize
query.put("types",types)
Dim columns As List
columns.Initialize
columns.AddAll(Array As String("Recommend.Other|5","Recommend.All|5","Recommend.MA|5"))
symbols.Put("tickers",tickers)
symbols.Put("query",query)
vals.Put("symbols", symbols)
vals.Put("columns",columns)
Dim k As JSONGenerator
k.Initialize(vals)
Log(k.ToString)
' "{" & Chr(34) & "symbols" & Chr(34) & ":{" & Chr(34) & "tickers" & Chr(34) & ":[" & Chr(34) & fx & Chr(34) & "]," & Chr(34) & "query" & Chr(34) & ":{" & Chr(34) & "types" & Chr(34) & ":[]}}," & Chr(34) & "columns" & Chr(34) & ":[" & Chr(34) & "Recommend.Other|15" & Chr(34) & "," & Chr(34) & "Recommend.All|15" & Chr(34) & "," & Chr(34) & "Recommend.MA|15" & Chr(34) & "]}"
check.Initialize("", Me)
' check.PostMultipart("https://scanner.tradingview.com/forex/scan", vals, Null)
check.PostString("https://scanner.tradingview.com/forex/scan", k.tostring)
check.GetRequest.SetHeader("Accept","*/*")
check.GetRequest.SetContentEncoding("gzip, deflate, br")
check.GetRequest.SetHeader("Accept-Language", "de,en-US;q=0.7,en;q=0.3")
check.GetRequest.SetHeader("Cache-Control","no-cache")
check.GetRequest.SetHeader("Connection","keep-alive")
check.GetRequest.SetContentType("application/x-www-form-urlencoded")
check.GetRequest.SetHeader("DNT","1")
check.GetRequest.SetHeader("Host", "scanner.tradingview.com")
check.GetRequest.SetHeader("Origin", "https://tradingview.com")
check.GetRequest.SetHeader("Pragma", "no-cache")
check.GetRequest.SetHeader("TE", "Trailers")
check.GetRequest.SetHeader("User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:77.0) Gecko/20100101 Firefox/77.0")
wait for (check) JobDone(job As HttpJob)
If job.Success Then
Log(job.GetString)
Else
Log("Error:")
Log(job.ErrorMessage)
End If
job.release
End Sub
The JSON String is
same as original.{"symbols":{"tickers":["FX:USOIL"],"query":{"types":[]}},"columns":["Recommend.Other|5","Recommend.All|5","Recommend.MA|5"]}
The response should be like
but response is{ "data":[{"s":"FX:USOIL","d":[-0.09090909,-0.44545455,-0.8]}],"totalCount":1}
{ "data":[],"totalCount":0}
Did i oversee something important or is there a much easier way?
Thanks for replies and your time.