Jump to content

Yahoo Finance and PHP script issue


linuxsoft

Recommended Posts

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.