实时抓取YAHOO股票报价的代码

栗子492

栗子492

2016-01-29 14:28

实时抓取YAHOO股票报价的代码,实时抓取YAHOO股票报价的代码
  <?
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)."n";  
            if (strstr($buffer, "rowspan=3"))
            {
                //echo "extract started at line #$lineCountn";  
                $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("nr", " ", "$buffer");
                if (strstr($buffer, "http://ichart.yahoo.com/v?s=$stockSymbol"))  
                {
                    //echo "ichart found!";
                    $stopExtract = 1;  
                }
                $capturedHTML .= $buffer;     
         
            }
            if ($startExtract &&
展开更多 50%)
分享

猜你喜欢

实时抓取YAHOO股票报价的代码

PHP
实时抓取YAHOO股票报价的代码

股票报价的WebService之三

ASP
股票报价的WebService之三

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

股票报价的WebService之五

ASP
股票报价的WebService之五

股票报价的WebService之一

ASP
股票报价的WebService之一

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

股票报价的WebService之二

ASP
股票报价的WebService之二

股票报价的WebService之四

ASP
股票报价的WebService之四

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

杏林同学录(二)

杏林同学录(二)

用Indy组件开发Socket应用程序

用Indy组件开发Socket应用程序
下拉加载更多内容 ↓