Is It Possible to Retrieve Data From An Url ?

Previous topic - Next topic

fasasoftware



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 :(

MrPlow

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

Comp:
Speccy-48k, Speccy-128k, Amigas, PCs

fasasoftware

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

CptnRoughnight

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.

fasasoftware

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



Qedo

Remove http:// and add SHOWSCREEN before MOUSEWAIT

fasasoftware

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




spacefractal

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.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

Kitty Hello

You can use sock... to asynchronically get bits..

Schranz0r

I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard