GLBasic forum

Main forum => GLBasic - en => Topic started by: fasasoftware on 2016-May-09

Title: Is It Possible to Retrieve Data From An Url ?
Post by: fasasoftware on 2016-May-09


Dear friends,

Well, i need please an help with fresh code for a project of mine...

I need to retrieve every second the value of some money pairs...but for example is ok for one...

1) first of all i have registered me to true.fx ...

2) this is a demo url without my registration of course but working... :
http://webrates.truefx.com/rates/connect.html?f=html&c=AUD/USD

this give this result: AUD/USD 1462567500019 0.73667 0.73681 0.73373 0.74784 0.74643

I need to retrieve the last value  0.74643

the first value from right, to work and put it into a variable and update every second

So i don't know if i must get my url and retrieve that data?
..any idea?? thanks a lot in advance
Lestroso :(
Title: Re: Is It Possible to Retrieve Data From An Url ?
Post by: MrPlow on 2016-May-09
Hi There

Yes, you can collect via html using

Code: GLBasic [Select]

data$=NETWEBGET$("www.sitename.com","/pagename.html",80,512,5000)


 

Then parse it using split function like so...

Code: GLBasic [Select]

LOCAL splits$[]

        num = SPLITSTR(data$, splits$[], " ") // using space as delimiter
                IF num>0
                FOR i=0 TO num-1
                        PRINT ""+splits$[i]+"", 70, 100+(20*(i+1))
                NEXT
                ELSE
                        PRINT "No Connection", 70, 120
                ENDIF

        ENDIF

 
Title: Re: Is It Possible to Retrieve Data From An Url ?
Post by: fasasoftware on 2016-May-09
hI.... I  have tryed your software ...but don't work...can you help me??  please??? i have write this...:

Code: GLBasic [Select]

// --------------------------------- //
// Project: VALORI
// Start: Monday, May 09, 2016
// IDE Version: 14.106


// SETCURRENTDIR("Media") // go to media files


data$=NETWEBGET$("http://webrates.truefx.com","/rates/connect.html?f=html&c=AUD/USD",80,512,5000)


LOCAL splits$[]
 
        num = SPLITSTR(data$, splits$[], " ") // using space as delimiter
               
                IF num>0
                FOR i=0 TO num-1
                        PRINT ""+splits$[i]+"", 70, 100+(20*(i+1))
                NEXT
                ELSE
                        PRINT "No Connection", 70, 120
                ENDIF

        ENDIF

 


_______________________________________
*** Configuration: WIN32 ***
precompiling:
GPC - GLBasic Precompiler V.10.037 SN:9655d67f - 3D, NET
"VALORI.gbas"(25) error : GPC000d ENDIF without IF


If i delete the last endif give this...



_______________________________________
*** Configuration: WIN32 ***
precompiling:
GPC - GLBasic Precompiler V.10.037 SN:9655d67f - 3D, NET
"VALORI.gbas"(10) error : GPC1002 variable is not explicitly defined : data$


Can you help help me?

LESTROSO
Title: Re: Is It Possible to Retrieve Data From An Url ?
Post by: CptnRoughnight on 2016-May-09
you have to declare data$ as global. You can switch this in the options off but i don't recommend this.

Code: GLBasic [Select]
GLOBAL data$=NETWEBGET$("http://webrates.truefx.com","/rates/connect.html?f=html&c=AUD/USD",80,512,5000)
 

The last ENDIF is wrong.
Title: Re: Is It Possible to Retrieve Data From An Url ?
Post by: fasasoftware on 2016-May-09
Nothing works here...:
i have added some code but nothing.....i see nothing... did you try it??

Code: GLBasic [Select]

// --------------------------------- //
// Project: VALORI
// Start: Monday, May 09, 2016
// IDE Version: 14.106


// SETCURRENTDIR("Media") // go to media files


GLOBAL data$=NETWEBGET$("http://webrates.truefx.com/rates/connect.html?f=html&c=AUD/USD",80,512,5000)

 


LOCAL splits$[]

  LOCAL  num = SPLITSTR(data$, splits$[], " ") // using space as delimiter

                IF num>0
                FOR i=0 TO num-1
                        PRINT ""+splits$[i]+"", 70, 100+(20*(i+1))
                NEXT
                ELSE
                        PRINT "No Connection", 70, 120
                ENDIF

MOUSEWAIT


 
Title: Re: Is It Possible to Retrieve Data From An Url ?
Post by: Qedo on 2016-May-09
Remove http:// and add SHOWSCREEN before MOUSEWAIT
Title: Re: Is It Possible to Retrieve Data From An Url ?
Post by: fasasoftware on 2016-May-10
Thanks a lot!! now it works fine...Best Regards, Lestroso...

Code: GLBasic [Select]
// --------------------------------- //
// Project: VALORI
// Start: Monday, May 09, 2016
// IDE Version: 14.106


// SETCURRENTDIR("Media") // go to media files


GLOBAL data$=NETWEBGET$("webrates.truefx.com","/rates/connect.html?f=html&c=AUD/USD",80,512,5000)




LOCAL splits$[]

  LOCAL  num = SPLITSTR(data$, splits$[], " ") // using space as delimiter

                IF num>0
                FOR i=0 TO num-1
                        PRINT ""+splits$[i]+"", 70, 100+(20*(i+1))
                NEXT
                ELSE
                        PRINT "No Connection", 70, 120
                ENDIF
SHOWSCREEN

MOUSEWAIT



 
Title: Re: Is It Possible to Retrieve Data From An Url ?
Post by: spacefractal on 2016-May-10
Also the biggest issue with NETWEBGET, is NETWEBGET should been done in a thread, newer in the main thread. This is something that should have been in a background aktivity. Hopefuly that can been fixed in the future.
Title: Re: Is It Possible to Retrieve Data From An Url ?
Post by: Kitty Hello on 2016-May-11
You can use sock... to asynchronically get bits..
Title: Re: Is It Possible to Retrieve Data From An Url ?
Post by: Schranz0r on 2016-May-12
or http://www.glbasic.com/forum/index.php?topic=3642.0