没有出错信息,提示:没有检索到信息。我怀疑出错的地方是:
1:
 
$theurl="http://quote.stockstar.com/stock/external_quote.aspcode=shag600728".$stock;     联接对方网页出错2:$pattern="(^[成交]+\\\$[0-9]+\\[0-9]+)";
这个正则表达式出错,但不知道怎样改。帮帮忙,看一看问题出在哪?

解决方案 »

  1.   

    1、http://quote.stockstar.com/stock/external_quote.asp?code=shag600728已是“新太科技”2、得到的数据为
    ...
    <table border="0" cellspacing=0 width="100%">
          <tr bgcolor="#F5F5F5">
            <td nowrap> 成交</td>
            <td align=right ><font color="red"> 7.78</font></td>
            <td width=12><img src="images/spacer.gif" width=12 height=1></td>
            <td align=right nowrap> 涨跌</td>
            <td align=right > <font color="red">0.71</font></td>
          </tr>
    ....假定保存于$text中,则
    $text = preg_replace("/成交.+/","\\0",$text); // 提取从“成交”开始的数据
    $text = strip_tags($text); // 删除html标记
    preg_match_all("/(成交|涨跌)\s*([\d.-]+)/s",$text,$regs); // 提取数据
    // 输出数据
    foreach($regs[1] as $k=>$v)
      echo "$v : {$regs[2][$k]}<br>";
      

  2.   

    搞了半天,还是不太明白,楼上大哥能不能写全一点?谢谢了。还有我有两个PHP空间,一个会提示联接出错,一个就可以运行,但得不到想要的结果,是不是服务器设置不同?
      

  3.   

    xuzuning(唠叨) ( ) 说得很清楚了啊,仔细看看