$curl=&new Curl_HTTP_Client();
$html_data=$curl->fetch_url("http://hq.sinajs.cn/list=".$StockList,"",5);
$html_data=iconv("GB2312","UTF-8",$html_data);
$data='';
if($html_data)
{
preg_match_all("/str_(.+?)\";/is",$html_data,$data);
$messages=str_replace('="',",",$data[1]);
}
$list = '';
$i=0;
foreach($messages as $l)
{
$N=split(',',$l);
$N[0]=substr($N[0],2);
$cj = round($N[4]-$N[3],2);
$cjl = ceil($N[9]/100); //成交量(手)
$zdf = round(($N[4]-$N[3])*100/$N[4],2); //涨跌幅
$color = $cj>=0 ? '#FF0000' : '#008000';
$bgcolor = (($i+1)%2==0) ? '#F5F5F5' : '#ffffff';
if($N[4]==0) //停牌
{
$color = '#000000';
$N[4]= '--';
$cjl = '--';
$cj = '--';
$zdf = '--';
$N[7]='--';
$N[8]='--';
$N[2]='--';
$N[5]='--';
$N[6]='--';
}
$html .= '<tr align="center" bgcolor="'.$bgcolor.'" onMouseOver="this.style.background=\'#FDF0D7\';" onMouseOut="this.style.background=\''.$bgcolor.'\';">'; 
           $html .= '<td align="center"><input type="checkbox" id="check_id'.$FavIDList[$i].'" name="check_name" value="'.$N[0].'" style="cursor:hand"></td>';
           $html .= "<td align=\"center\"><a href=\"javascript:ShowKline('".$N[0]."')\">".$N[0]."</a></td>"; //代码
           $html .= "<td align=\"center\"><a href=\"javascript:ShowKline('".$N[0]."')\">".$N[1]."</a></td>"; //名称
           $html .= '<td style="color:'.$color.'">'.$N[4].'</td> '; //当前价
           $html .= '<td>'.$cjl.'</td> '; //成交量
           $html .= '<td style="color:'.$color.'">'.($cj>0 ? '+'.$cj : $cj).'</td> '; //涨跌
           $html .= '<td style="color:'.$color.'">'.($cj>0 ? '+' : '').$zdf.'</td> '; //涨跌幅
           $html .= '<td>'.$N[7].'</td>'; //买价
           $html .= '<td>'.$N[8].'</td>'; //卖价
           $html .= '<td>'.$N[2].'</td> '; //开盘价
           $html .= '<td style="color:#FF0000">'.$N[5].'</td> '; //最高价
          $html .= '<td style="color:#008000">'.$N[6].'</td> '; //最低价
           $html .= '<td style="color:#000000">'.$N[3].'</td> '; //昨收价
           $html .= '<td align="center">'.$N[32].'</td> '; //时间
          $html .= ' <td align="center"><input type="button" name="btn_order" class="button3" value="下单"';
if($IsOpen==0) 
{
$html.=' disabled';
}
else
{
$html.=' onClick="location.href=\'order.php?do=order&stockcode='.$N[0].'\';"';
}
$html.=' /></td> ';
         $html .= '</tr> ';
$i++;
}

解决方案 »

  1.   

    点下按钮,就可以把当天除权除息的股票列出来,这意味着:你要获得所有股票的信息,而不是某几个股票;
    获得的股票信息包含除权除息信息信息项。而新浪行情接口两个条件都不满足:
    一次只能获取指定几个股票(StockList)的数据,频繁访问估会被拒绝
     数据没有除权除息信息,这个你从返回的数据就能看出来。不知道你是不是要做股票数据分析,是的话靠这样获取数据是不行的,需要更专业的数据获取办法,专业的数据数据量A股一个交易就有好几百兆!