Forum Moderators: coopster

Message Too Old, No Replies

Yahoo Finance CSV + fopen

fopen messing up the Yahoo Finance data randomly

         

machonemedia

8:18 pm on Jul 18, 2011 (gmt 0)

10+ Year Member



Hi,

I have a test page here: [tradingrecord.com...]

If you refresh 5 or so times you'll notice the data gets messed up.

I have done the same with:

[finance.yahoo.com...]

The source data looks fine when I refresh that page a bunch of times. So it seems like when it's coming through fopen() it randomly gets garbled. Looks like it's due to some special characters.


if(($handle = fopen('http://finance.yahoo.com/d/quotes.csv?s=AMZN&f=snxl1bc1d1t1jkmj1op2ahvet8ydpa2rb6', 'r')) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ',')) !== FALSE) {
print_r($data);
}
}
fclose($handle);
exit;



This was working up until last weekend (Saturday or Sunday) so I have no idea what changed. yum may have updated something but I ended up upgrading to PHP 5.3.3 and it still happens.

Really stumped as to what happened and what could be the problem.

Anybody have an idea of what it could be or any solutions?

Thanks,
Bryan

penders

9:00 pm on Jul 18, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Does Yahoo Finance have an official API? I can't seem to find much on it?

(I doubt that upgrading PHP would help in this respect.)

machonemedia

9:11 pm on Jul 18, 2011 (gmt 0)

10+ Year Member



No official API docs that I know of. There are a few websites/blogs that posted what all the field types were ("snxl1bc1d1t1jkmj1op2ahvet8ydpa2rb6") but that's it.

I have been trying to find any information on if they are upgrading or changing something and ended up just contacting Yahoo directly, waiting for a response.