How i can retrieve datas from this url?

Just starting out? Need help? Post your questions and find answers here.
Fasasoftware
Posts: 47
Joined: Tue May 26, 2015 11:22 pm

How i can retrieve datas from this url?

Post by Fasasoftware »

Dear Friend,

i need to retrieve these forex data from this url : http://webrates.truefx.com/rates/connect.html?f=html

and put them into variables like eur/usd, and the other currency from this url... but is good to take the last value

to make more simple the code..

i need to refresh this data every second...

I thank you a lot in adavance,...

As soon as possible i think to buy This wonderful Software -SpiderBasic!!!! I have purchased some years ago the PureBasic Compiler And I'm very happy. :D

Lestroso :oops:

www.fasasoftware.com
User avatar
Peter
Posts: 1197
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: How i can retrieve datas from this url?

Post by Peter »

Hello Lestroso,

that's not that easy.

You cannot get the data directly from webrates.truefx.com using HTTPRequest() because of the Same-origin policy.

But you can build a little proxy to get your data. If you are familiar with PHP (and you own a webserver like Apache) you can write something like this:

Code: Select all

<?php
header('Access-Control-Allow-Origin: *');  
echo file_get_contents("http://webrates.truefx.com/rates/connect.html?f=html");
?>
and now you are able to access the PHP-Script which serves you the needed data:

Code: Select all

Procedure HttpGetEvent(Success, Result$, UserData)
 If Success
  Debug Result$
 Else
  Debug "HTTPRequest(): Error"
 EndIf
EndProcedure

URL.s = "http://127.0.0.1/GetRequest.php"
HTTPRequest(#PB_HTTP_Get, URL, "", @HttpGetEvent())
Greetings ... Peter
Fasasoftware
Posts: 47
Joined: Tue May 26, 2015 11:22 pm

Re: How i can retrieve datas from this url?

Post by Fasasoftware »

tHANK you Peter...

yes it's a little complicated....but i need to try your code....Thanks again...

Lestroso :)
Post Reply