linuxsoft Posted February 18, 2012 Share Posted February 18, 2012 It seems something has changed at Yahoo Finance. I use a Stock quote script (micro stock) to post stock quotes from specific tickers on my website. It worked fine for years until recently. Now i am unable to access any data directly from any Yahoo finance URL. Hereafter my script which comes from 1) Micro Stock : http://www.phptoys.com/product/micro-stock.html or 2) Getting Stock Quote : http://www.phptoys.com/tutorial/getting-stock-quote.html <?php function getStockSite($stockLink){ if ($fp = fopen($stockLink, 'r')) {$content = ''; while ($line = fread($fp, 1024)) {$content .= $line;}} return $content;} function processStockSite($wurl){ $wrss = getStockSite($wurl); $text = ''; if (strlen($wrss)>100){ // Get text $spos = strpos($wrss,'</span>:',$spos)+3; $spos = strpos($wrss,'<big>',$spos); $epos = strpos($wrss,'</div><h1>',$spos); if ($epos>$spos){ $text = substr($wrss,$spos,$epos-$spos);} else {$text = '-';}} // Get results $result['text'] = $text; return $result;} <html> <head> <title>Get Stock tutorial</title> </head> <body> <?php // Get stock data $data = processStockSite('http://finance.yahoo.com/q?s=GOOG'); echo $data['text']; ?> I am not php programmer and i hope someone can help me in this matter since that script was a marvel. Thank in advance. Quote Link to comment https://forums.phpfreaks.com/topic/257249-yahoo-finance-and-php-script-issue/ Share on other sites More sharing options...
Pikachu2000 Posted February 18, 2012 Share Posted February 18, 2012 There could be many reasons. Right after the <?php tag at the top of the script, temporarily add the following code so any generated errors are displayed. Upload the edited file, load it, and see if it gives you any insight. error_reporting(-1); ini_set('display_errors', 'On'); Quote Link to comment https://forums.phpfreaks.com/topic/257249-yahoo-finance-and-php-script-issue/#findComment-1318640 Share on other sites More sharing options...
PaulRyan Posted February 18, 2012 Share Posted February 18, 2012 I believe Yahoo have changed the source code they use, a quick search of the outputted HTML shows that "<big>" does not exist, so it cannot be found, thus the function will not work. This function needs edited to work with the new source code, but I doubt anyone will just "do it for you" Regards, PaulRyan. Quote Link to comment https://forums.phpfreaks.com/topic/257249-yahoo-finance-and-php-script-issue/#findComment-1318647 Share on other sites More sharing options...
linuxsoft Posted February 18, 2012 Author Share Posted February 18, 2012 Thanks Paul, it sounds logical. I will be back to my drawing table. Regards. Martin Roy Quote Link to comment https://forums.phpfreaks.com/topic/257249-yahoo-finance-and-php-script-issue/#findComment-1318662 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.