I am having trouble getting a stock quote from a website and posting it on my website. Here is the code I am using now, and it wont pull the info out. Would anyone have any revisions to this code using the URL posted in $theurl. I need to get the latest stock quote.
Thanks
<?php
// choose stock to look at
$symbol='Breakwater Resources';
echo "<h1>Stock Quote for $symbol</h1>";
$theurl='http://www.tdwaterhouse.ca/quote.jsp?s144=stocks%2Fstocks.overview.txt&ssn=o&sn=s&i9=625&sTier=temp&slanguage=English&sIssue.Ticker=bwr&scountry=ca&x=6&y=16';
if (!($fp = fopen($theurl, 'r')))
{
echo 'Could not open URL';
exit;
}
$contents = fread($fp, 1000000);
fclose($fp);
//echo $contents;
// find the part of the page we want and output it
$pattern = "(\\$[0-9 ]+\.[0-9]+)";
if (eregi($pattern, $contents, $quote))
{
echo "$symbol was last sold at: ";
echo $quote[1];
} else
{
echo 'No quote available';
};
// acknowledge source
echo '<br />'
.'This information retrieved from <br />'
."<a href=\"$theurl\">$theurl</a><br />"
.'on '.(date('l jS F Y g:i a T'));
?>