Author Topic: Is It Possible to Retrieve Data From An Url ?  (Read 2265 times)

Offline fasasoftware

  • Mc. Print
  • *
  • Posts: 20
    • View Profile


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

Offline MrPlow

  • Prof. Inline
  • *****
  • Posts: 1442
    • View Profile
Re: Is It Possible to Retrieve Data From An Url ?
« Reply #1 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

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

Offline fasasoftware

  • Mc. Print
  • *
  • Posts: 20
    • View Profile
Re: Is It Possible to Retrieve Data From An Url ?
« Reply #2 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

Offline CptnRoughnight

  • Mr. Polyvector
  • ***
  • Posts: 114
    • View Profile
Re: Is It Possible to Retrieve Data From An Url ?
« Reply #3 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.
Es ist kein Mond....

A young band from Thuringia with a lot of potential :
http://youtu.be/diMBlNspsD8

Offline fasasoftware

  • Mc. Print
  • *
  • Posts: 20
    • View Profile
Re: Is It Possible to Retrieve Data From An Url ?
« Reply #4 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


 

Offline Qedo

  • Mr. Polyvector
  • ***
  • Posts: 159
  • UNUS SED LEO
    • View Profile
Re: Is It Possible to Retrieve Data From An Url ?
« Reply #5 on: 2016-May-09 »
Remove http:// and add SHOWSCREEN before MOUSEWAIT

Offline fasasoftware

  • Mc. Print
  • *
  • Posts: 20
    • View Profile
Re: Is It Possible to Retrieve Data From An Url ?
« Reply #6 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



 

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3606
    • View Profile
    • Space Fractal
Re: Is It Possible to Retrieve Data From An Url ?
« Reply #7 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.
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10695
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: Is It Possible to Retrieve Data From An Url ?
« Reply #8 on: 2016-May-11 »
You can use sock... to asynchronically get bits..

Offline Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 5013
  • O Rly?
    • View Profile
I <3 DGArray's :D

PC:
AMD RYzen 7 1700 @3.9Ghz, 16GB HyperX Fury 2666Mhz Ram, ASUS ROG GTX 1060 STRIX 6GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard