April 27, 2024, 03:17:45 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Pulling Web Site Data Into String?

Started by Mark1Up, January 05, 2007, 10:16:49 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Mark1Up

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

LarryMc

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
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Mark1Up

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

LarryMc

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.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Mark1Up

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

Jerry Muelver

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

Mark1Up

Jerry, thanks for the nudge.  I was getting wrapped up in the Browser commands and didn't look at that example.

Mark

Rock Ridge Farm (Larry)

I posted am Aurora demo that did that - I can find it if it would help.