By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,067 Members | 1,818 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,067 IT Pros & Developers. It's quick & easy.

partial ot ... stock market feed

P: n/a
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
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"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;
}
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.