Total members 11893 |It is currently Wed Nov 06, 2024 5:38 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





PHP code to get yahoo stock data

i have write a php code to get yahoo stock data , when i fetch the web data it saves the data as text file in to host server local drive (c:\ ), but i want to save the yahoo stock data from any remote pc from where i browse the page and it saves the data as text file automatically in local pc's c drive .
is there any way to do this , please help...........
here is the code

Code:
 
$quotes 
=array('DOW','SPX','GOLD','OIL','AIG','APPLE','AMGN','BAC','DISH',
'DO','DIRECTV','FEDEX','GOOG','HD','IBM','INTEL','IP','COLA','LOWES',
'YEN','EUR' ,'HK','JAP','AUS','INDIA');
//here you can out symbols of stock data
$args   = implode('&s=', $quotes);
//$file   = fopen("http://finance.yahoo.com/d/quotes.csv?s=$args&f=slp11d1t1c1ohgv&ej3j1x=.csv", "rb");
 $file   = fopen ("http://finance.yahoo.com/d/quotes.csv?s=$args&f=noc1&ex=.csv","r");
$data   = array();
$table  = '';

if ($file) {
  while($stocks = fgetcsv($file)) {
    $data[$stocks[0]] = $stocks;
  }
  fclose($file);
}

$table .= "<table border='1'>\n";
$table .= "<tr><th colspan='5'>".date('Y-m-d h:i:s A')."</th></tr>\n";
$table .= "<tr>\n";
foreach ($data as $sym => $info) {
  $table .= "\t<th>$sym</th>\n";
  foreach ($info as $item) {
    $table .= "\t<td>$item</td>\n";
  }
  $table .= (end($data) == $info) ? "</tr>\n" : "</tr>\n<tr>\n";
}
$table .= "</table><br/>";
echo $table;
//file_put_contents('stocks.html', $table, FILE_APPEND);
file_put_contents('C:\stocks.rtf', $table);
 





Author:
Newbie
User avatar Posts: 1
Have thanks: 0 time

Here is how you do it:
Code:
//echo $table;
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Type: html");
header("Content-Disposition: attachment;filename=mystock.html;");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".strlen($table));
set_time_limit(0);
echo $table;

//file_put_contents('stocks.html', $table, FILE_APPEND);
//file_put_contents('C:\stocks.rtf', $table);



Author:
Newbie
User avatar Posts: 1
Have thanks: 0 time
Post new topic Reply to topic  [ 2 posts ] 

  Related Posts  to : php code to get yahoo stock data
 Huffman Data compression-decompression code C#-csharp     -  
 LZW data compression-decompression algorithm java code     -  
 Arithmetic data comparison and decompression java code     -  
 stock follow up     -  
 Learn Technical analysis and stock market tricks for free     -  
 i want code for connecting mobile and pc can u send me code     -  
 Freeman chain code algorithm code     -  
 Data set for ID3 algorithm     -  
 What is Data integration?     -  
 c++/data structure     -  



cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com