欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

實(shí)時(shí)抓取YAHOO股票報(bào)價(jià)的代碼

 更新時(shí)間:2006年10月09日 00:00:00   作者:  
<?
function getYahooQuote($stockSymbol = "CCR")
{
if (!$targetURL) $targetURL = "http://finance.yahoo.com/q?s=$stockSymbol&d=t"; //設(shè)定要抓取的URL目標(biāo)     
        $fd = fopen("$targetURL", "r");
        $stopExtract = 0;  
        $startExtract = 0;  
        while (!feof($fd))  
        {
            $buffer = fgets($fd, 4096);
                //echo trim($buffer)."\n";  
            if (strstr($buffer, "rowspan=3"))
            {
                //echo "extract started at line #$lineCount\n";  
                $startExtract = 1;  
            }     
            if ($startExtract && !$stopExtract)     
            {

                if (strstr($buffer, "<a"))  
                {
                    $startPos = strrpos($buffer, "<");
                    $buffer = substr($buffer, $startPos);
                }
                //$text = trim(strip_tags($buffer));
                //echo trim($buffer)."\n";  

                $buffer = str_replace("\n\r", " ", "$buffer");
                if (strstr($buffer, "http://ichart.yahoo.com/v?s=$stockSymbol"))  
                {
                    //echo "ichart found!";
                    $stopExtract = 1;  
                }
                $capturedHTML .= $buffer;     

            }
            if ($startExtract && strstr($buffer, "<br>"))
            {
                 $stopExtract = 1;  
                //echo "extract stopped at line #$lineCount\n";          
                echo $capturedHTML;
                break;
            }
            $lineCount++;
        }
        fclose($fd);
    }

    //以下為抓取的一個(gè)例子
    $symbols = array('CCR', 'IIXL','SAPE','WBVN' );
    $symbolCount = count($symbols);
    for ($i=0; $i< $symbolCount; $i++)
    {
        echo "$symbols[$i]<br>";
        getYahooQuote("$symbols[$i]");
    }
    ?>


相關(guān)文章

  • PHP join()函數(shù)用法與實(shí)例講解

    PHP join()函數(shù)用法與實(shí)例講解

    今天小編就為大家分享一篇關(guān)于PHP join()函數(shù)用法與實(shí)例講解,小編覺(jué)得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來(lái)看看吧
    2019-03-03
  • php學(xué)習(xí)筆記 數(shù)組遍歷實(shí)現(xiàn)代碼

    php學(xué)習(xí)筆記 數(shù)組遍歷實(shí)現(xiàn)代碼

    php學(xué)習(xí)筆記 數(shù)組遍歷實(shí)現(xiàn)代碼,需要的朋友可以參考下。
    2011-06-06
  • 最新評(píng)論