Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 17th, 2005, 10:59 AM
Chris Mosser
Guest
 
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


  #2  
Old July 17th, 2005, 11:00 AM
Erwin Moller
Guest
 
Posts: n/a
Default Re: partial ot ... stock market feed

"Chris Mosser" <cmosser_at_comcast_dot_net> wrote:
[color=blue]
> 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[/color]

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;
}


 

Bookmarks

Thread Tools

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

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles