Total members 9936 | Gratitudes |It is currently Sun Feb 05, 2012 8:29 pm Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 2 posts ] 
Author Question
 Question 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  
Reply with quote  
 Question 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  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 2 posts ] 
Quick reply


  


 Similar topics
 Topic title   Forum   Author   Comments 
 Read your gmail using Java code  Java examples  msi_333  5
 What's wrong with my code?  Java  Anonymous  3
 project source code in java  Java  Anonymous  0
 Ajax Source code to Suggest application with JSP Server side  AJAX  msi_333  5
 java code to open word doc attached in ms access.db  Java  Anonymous  0

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: No registered users and 1 guest



Jump to:  
Previous Question | Next Question 




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-2011
mileX v1.0 designed by codemiles team