PHP Stock Quote Web ServiceYahoo finance provides webservice. Basically when you access the url http://finance.yahoo.com/d/quotes.csv?s=AMZN&f=l1, you are accessing the yahoo webservice which pulls the data you requested. In the above url I am making an inquiry about AMZN (amazon.com). The sl1c1, tells the web service that you want the stock symbol (s) along with the last close (l1) and the net change (c1). For a full list of codes see http://www.gummy-stuff.org/Yahoo-data.htm.
The format it returns is as a csv. Now you can open a csv in excel, or openoffice if you choose, however it is simple to have a php parse the csv and display the results on your webpage. <?php //Dow is ^DJI //Nasdaq is ^IXIC //S&P is ^GSPC $arr = array('AAPL','AMZN','DELL','EBAY','GOOG','NFLX','YHOO'); //codes like sl1c1d1 defined in http://www.gummy-stuff.org/Yahoo-data.htm $url= "http://finance.yahoo.com/d/quotes.csv?s=".implode("+", $arr)."&f="."sl1c1d1"; echo "<table>"; $handle = fopen($url, "r"); while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { echo "<tr>"; foreach($data as $d) echo "<td>$d</td>"; echo "</tr>"; } fclose($handle); echo "</table>"; ?> Tags: php | Related Articles php Calculate Script Duration in PHP and... Generate CSV Spreadsheet with PHP Generate PDFs with PHP Generate XLS Spreadsheet files with ... How to properly escape inline javasc... HTML Table Row Highlight PHP - Resize an Image with GD PHP Calculate Duration of MP3 PHP Create Zip file PHP mail Function With Attachments |