function getYahooQuote($stockSymbol = "CCR")
{
if (!$targetURL) $targetURL = "http://finance.yahoo.com/q?s=$stockSymbol&d=t"; //設定要抓取的URL目标
$fd = fopen("$targetURL", "r");
$stopExtract = 0;
$startExtract = 0;
while (!feof($fd))
{
$buffer = fgets($fd, 4096);
//エコートリム($buffer)。」
";
if (strstr($buffer, "rowspan=3"))
{
//echo " #$lineCount 行目で抽出が開始されました
";
$startExtract = 1;
}
if ($startExtract && !$stopExtract)
{
if (strstr($buffer, "{
$startPos = strrpos($buffer, "$buffer = substr($buffer, $startPos);
//$text = トリム(strip_tags($buffer))
//エコー トリム($buffer);
";
$buffer = str_replace("
", " ", "$buffer");
if (strstr($buffer, "http://ichart.yahoo.com/v?s=$stockSymbol"))
{
//echo "ichart が見つかりました!" ;
$stopExtract = 1;
$capturedHTML .= $buffer;
} |