partial ot ... stock market feed

This is a discussion on partial ot ... stock market feed within the PHP Language forums, part of the PHP Programming Forums category; I'm looking to add a page to my site where I can get stock quotes for the wired, but ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-13-2004
Chris Mosser
 
Posts: n/a
Default partial ot ... stock market feed

I'm looking to add a page to my site where I can get stock quotes for the
wired, but more importantly, the wireless web(ie my cell phone). I know how
write the needed php and WAP application, I just don't know where to get the
stock market feed, at least not without parsing a finance.yahoo.com page.
Or something else like it that could change at any time. I'm looking for
just the raw data feed. Anyone ever had to do this and can give me some
info on a feed??????

--
Chris Mosser


Reply With Quote
  #2 (permalink)  
Old 12-13-2004
Erwin Moller
 
Posts: n/a
Default Re: partial ot ... stock market feed

"Chris Mosser" <cmosser_at_comcast_dot_net> wrote:

> I'm looking to add a page to my site where I can get stock quotes for the
> wired, but more importantly, the wireless web(ie my cell phone). I know
> how write the needed php and WAP application, I just don't know where to
> get the stock market feed, at least not without parsing a
> finance.yahoo.com page.
> Or something else like it that could change at any time. I'm looking for
> just the raw data feed. Anyone ever had to do this and can give me some
> info on a feed??????
>
> --
> Chris Mosser


Hi

I just wrote a bunch of them. :P
You CAN use Yahoo without parsing the HTML.
Use their http://quote.yahoo.com/download/quotes.csv

Here follows a clumsy script to get you going:
(sorry, I think I exceed linelength, you have to repair by hand)


Regards,
Erwin Moller


function getAllQuotes($symbolsarray) {
// returns an array with arrays with data
$allQuotes = array();

$baseurl =
"http://quote.yahoo.com/download/quotes.csv?format=snlx&ext=.csv&symbols=";
// make the symbols urlencoded.
$urlsymbols = urlencode(implode(" ",$symbolsarray));

$quotesURL = $baseurl.$urlsymbols;

$csv = file($quotesURL);

foreach ($csv as $line_num => $line) {
// if NOT exists format: "^AEX2","^AEX2", "N/A - <b>0.00</b>",
"N/A"
// if exists format: "^AEX" ,"AEX-Index","7:37
am - <b>326.71</b>", "Amsterdam"
//
"AHOc.BA","ROYAL AHOLD","Aug 28, 2002 - <b>16.435</b>","Buenos Aires"
//
"MSFT.AS","MICROSOFT CORP","Oct 20 - <b>27.82</b>","Amsterdam"

// Please not the , in the date of AHOc.BA

// shame I don't know a better value for the 'format' in the baseurl.
:-(

// split on ","
$parts = explode("\",\"",$line);
$oneQuote = array();
$oneQuote["symbol"] = trim(trim($parts[0]) , "\"");
$oneQuote["name"] = trim(trim($parts[1]) , "\"");
$oneQuote["place"] = trim(trim($parts[3]) , "\"");

$val = trim($parts[2] , "\"");

// remove all before <b> and remove the last </b>
// remove 6:30am - <b>
$val = substr($val, strpos($val, "<b>")+3) ;

// remove </b>
$val = substr($val , 0 , -4) ;

$oneQuote["value"] = $val;

// add to allQuotes
$allQuotes[$oneQuote["symbol"]] = $oneQuote;
}
return $allQuotes;
}


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 09:22 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0