【php开源代码栏目提醒】:网学会员在php开源代码频道为大家收集整理了lookup.php提供大家参考,希望对大家有所帮助!
<html>
<head>
<title>Stock Quote from NASDAQ</title>
</head>
<body>
<?php
// choose stock to look at
$symbol='AMZN';
echo "<h1>Stock Quote for $symbol</h1>";
$theurl="http://www.amex.com/equities/listCmp/EqLCDetQuote.jsp?Product_Symbol=$symbol";
if (!($contents = file_get_contents($theurl)))
{
echo 'Could not open URL';
exit;
}
// find the part of the page we want and output it
$pattern = '(\\$[0-9 ]+\\.[0-9]+)';
if (eregi($pattern, $contents, $quote))
{
echo "<p>$symbol was last sold at: ";
echo $quote[1];
echo '</p>';
}
else
{
echo '<p>No quote available</p>';
};
// acknowledge source
echo '<p>'
.'This information retrieved from <br />'
."<a href=\"$theurl\">$theurl</a><br />"
.'on '.(date('l jS F Y g:i a T')).'</p>';
?>
</body>
</html>