set_time_limit(0);$getUrl = 'http://moneyflow.cnfol.com/Now.asp';$strPattern = '/<DIV style=\"WIDTH: 1390px\">(.*?)<!--分页-->/is';
$strContent = @file_get_contents($getUrl);preg_match($strPattern, $strContent, $strResult);
echo($strResult[1]);
对于上面这段代码,file_get_contents每次都能取到内容,可是preg_match有时能匹配到内容,有时又不行。不知道是什么原因,不知道大家有没有遇到过。在线急等,已经被折腾两天了。谢谢~

解决方案 »

  1.   

    应该是 file_get_contents 的问题,
    set_time_limit(0);$getUrl = 'http://moneyflow.cnfol.com/Now.asp';$strPattern = '/<DIV style=\"WIDTH: 1390px\">(.*?)<!--分页-->/is';
    $strContent = @file_get_contents($getUrl);preg_match($strPattern, $strContent, $strResult);
    echo $strContent;  // echo 出来看一下
    echo($strResult[1]);
      

  2.   

    可能长度超限制了,在php.ini增加
    pcre.backtrack_limit=-1
      

  3.   


    增加了这个也不行。。file_get_contents 每次都有内容。就是匹配不到内容。郁闷啊
      

  4.   


    $strPattern = '/<DIV style=\"WIDTH: 1390px\">(.*)<!--分页-->/is';
    preg_match 只匹配一次,看这个正则是不是能确定你要匹配的内容
      

  5.   

    你的 "/is"  改为 "/mis" 看看,(m:该选项将含有换行符的字符串视为多行而不是一行)