it's not so easy to retrieve this data via JavaScript because of security reasons.
With this code:
Code: Select all
#myWindow = 0
#myListIconGadget = 0
#myTimer = 0
Procedure HttpGetEvent(Success, Result$, UserData)
If Success
Debug Result$
; AUD/USD,1464101882768,0.71,855,0.71,863,0.71450,0.72290,0.72233
Result$ = ReplaceString(Result$, ",", #LF$)
AddGadgetItem(#myListIconGadget, -1, Result$)
Else
Debug "HTTPRequest(): Error"
EndIf
EndProcedure
Procedure Reload()
Protected URL.s = "http://webrates.truefx.com/rates/connect.html"
Protected Parameter.s = "c=AUD/USD&f=csv"
HTTPRequest(#PB_HTTP_Get, URL, Parameter, @HttpGetEvent())
EndProcedure
OpenWindow(#myWindow, 0, 0, 1000, 500, "Sbok", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ListIconGadget(#myListIconGadget, 10, 10, 900, 480, "CsvField1", 100)
For Counter = 1 To 8
AddGadgetColumn(#myListIconGadget, Counter, "CsvField" + Str(Counter + 1), 100)
Next
AddWindowTimer(#myWindow, #myTimer, 1000) ; 1 second..
BindEvent(#PB_Event_Timer, @Reload(), #myWindow, #myTimer)
you get the following error:
Therefore you have to create a little proxy (for example in php) and put it on your webserver:
Code: Select all
<?php
header('Access-Control-Allow-Origin: *');
echo file_get_contents('http://webrates.truefx.com/rates/connect.html?c=AUD/USD&f=csv');
?>
Then you can connect your proxy from SpiderBasic:
Code: Select all
#myWindow = 0
#myListIconGadget = 0
#myTimer = 0
Procedure HttpGetEvent(Success, Result$, UserData)
If Success
Debug Result$
Result$ = ReplaceString(Result$, ",", #LF$)
AddGadgetItem(#myListIconGadget, -1, Result$)
Else
Debug "HTTPRequest(): Error"
EndIf
EndProcedure
Procedure Reload()
Protected URL.s = "http://localhost/proxy.php"
Protected Parameter.s = ""
HTTPRequest(#PB_HTTP_Get, URL, Parameter, @HttpGetEvent())
EndProcedure
OpenWindow(#myWindow, 0, 0, 1000, 500, "Sbok", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ListIconGadget(#myListIconGadget, 10, 10, 900, 480, "CsvField1", 100)
For Counter = 1 To 8
AddGadgetColumn(#myListIconGadget, Counter, "CsvField" + Str(Counter + 1), 100)
Next
AddWindowTimer(#myWindow, #myTimer, 1000) ; 1 second..
BindEvent(#PB_Event_Timer, @Reload(), #myWindow, #myTimer)
Greetings ... Peter