It is currently Fri Jul 30, 2010 2:06 pm


All times are UTC [ DST ]


Ask on Codemiles community and get answers Free and Fast :

PHP codes,PHP tricks ,PHP faq ,PHP answers .and more

Our guest share with us your code snippets , your programming problems , your open source projects ,read articles and post yours .







Post new topic Reply to topic  [ 2 posts ] 
  Print view Previous topic | Next topic 
Author Message
 Post subject: php code to get yahoo stock data
PostPosted: Tue Nov 03, 2009 7:53 pm 
Offline
Newbie
User avatar

Joined: Tue Nov 03, 2009 7:48 pm
Posts: 1
Has thanked: 0 time
Have thanks: 0 time

hi

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



TOP
 Profile Send private message  
 
| More
 Post subject: Re: php code to get yahoo stock data
PostPosted: Wed Dec 16, 2009 5:51 pm 
Offline
Newbie
User avatar

Joined: Wed Dec 16, 2009 5:49 pm
Posts: 1
Has thanked: 0 time
Have thanks: 0 time

Here is how you do it:

//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);


TOP
 Profile Send private message  
 
| More
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 


 Similar topics
 Topic title   Forum   Author   Replies 
 What is the code for below algorithome.  C-C++  rasel  1
 race game source code in j2me  INDIA Jobs  sardar  0
 General Error: Style data  PHPbb3 support  Blinko  1
 calling method to form- displaying textbox data in messagbox  C#  jackjones2  1
 apriori algorithm java code  Java  yuva  2

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  





Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2009
mileX v1.0 designed by codemiles team