实时抓取yahoo股票报价的php代码

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); //echo trim($buffer).”
“; if (strstr($buffer, “rowspan=3”)) { //echo “extract started at line #$linecount
“; $startextract = 1; } if ($startextract && !$stopextract) { if (strstr($buffer, “{ $startpos = strrpos($buffer, “

Posted in 未分类