IonicWind Software

IWBasic => General Questions => Topic started by: Mark1Up on January 05, 2007, 10:16:49 PM

Title: Pulling Web Site Data Into String?
Post by: Mark1Up on January 05, 2007, 10:16:49 PM
I'm trying to figure out how I can pull data (stock market history) from the Yahoo Finance web page into a string within Ebasic so I can run my own parse and analysis on it.  The Yahoo Finance page provides the data in standard CSV format which will be easy to work with once I get into a string.  I tried playing around with the embedded browser commands but the closest command I saw was the GETPOSTDATA command and it didn't seem to do the trick (see code snippet).

I would appreciate any ideas as to how to get the data captured within Ebasic so I can use the data in my program.

Thanks,
Mark

DEF wb as WINDOW
DEF url as STRING
DEF stock[10000]:ISTRING
OPENWINDOW wb,0,0,640,480,@SIZE|@NOAUTODRAW|@MINBOX|@MAXBOX,0,"Get Stock History",&main

ATTACHBROWSER wb

BROWSECMD wb,@NAVIGATE,"http://ichart.finance.yahoo.com/table.csv?s=QQQQ&d=0&e=5&f=2007&g=d&a=0&b=1&c=2006"

run = 1
WAITUNTIL run=0
CLOSECONSOLE
CLOSEWINDOW  wb
END

SUB main
SELECT @MESSAGE
    CASE @IDCLOSEWINDOW
        run = 0
    CASE @IDBEFORENAV
        BROWSECMD(wb,@GETNAVURL, url, 255)
    CASE @IDNAVCOMPLETE
         OPENCONSOLE
         PRINT "Getting Stock History"
         PRINT url
         BROWSECMD(wb,@GETPOSTDATA, stock, 10000)
         PRINT stock
ENDSELECT
RETURN
ENDSUB
Title: Re: Pulling Web Site Data Into String?
Post by: LarryMc on January 05, 2007, 10:39:01 PM
There's info at the following link about downloading a file without using a browser window that was written for IBasic.  And if it worked in IBasic it will work in EBasic.

http://www.codingmonkeys.com/index.php?topic=71.msg601#msg601
Title: Re: Pulling Web Site Data Into String?
Post by: Mark1Up on January 06, 2007, 10:06:55 AM
Larry,

Thanks for the pointer.  That code looks somewhat complex but I will take a look.  I was hoping there might be a simple answer with the built-in brower commands but if not then I will dig into the API commands.

Mark
Title: Re: Pulling Web Site Data Into String?
Post by: LarryMc on January 06, 2007, 10:41:53 AM
that postdata command can be used to get the contents from a web page but it is triggered by a submit on the page.

I use that concept for a wysiwyg editor in an EBasic application.

But if I understand what you are trying to do is to download data and then read the file.

That's why I suggested what I did.

Larry

P.S.  Some of the slicker programmers in the forum still might have a slick way to do it.  I'm just not smart enough.
Title: Re: Pulling Web Site Data Into String?
Post by: Mark1Up on January 06, 2007, 03:58:55 PM
Actually, if I can just figure out how to access the data in the browser and get it into an ISTRING then I can manage it from there.  It doesn't need to be d/l to a file, although if that is a more straight forward method then I can work with the data from a file also.

Anyone else have any ideas?

Thanks,
Mark
Title: Re: Pulling Web Site Data Into String?
Post by: Jerry Muelver on January 06, 2007, 06:01:22 PM
Take a look at internet_example.eba in your sample projects --

REM example of how to use the internet functions in wininet.dll
REM the html source of the website is retrieved and displayed
Title: Re: Pulling Web Site Data Into String?
Post by: Mark1Up on January 06, 2007, 07:16:47 PM
Jerry, thanks for the nudge.  I was getting wrapped up in the Browser commands and didn't look at that example.

Mark
Title: Re: Pulling Web Site Data Into String?
Post by: Rock Ridge Farm (Larry) on January 07, 2007, 08:56:09 AM
I posted am Aurora demo that did that - I can find it if it would help.