preg_match_all

<meta charset="utf8">
<?php
set_time_limit (0);
for($i=1;$i<34;$i++){
    $url = "http://www.cnblogs.com/hellowzd/default.html?page=".$i;
    $str=file_get_contents($url);
    preg_match_all('|阅读\((.*?)\) 评论|i',$str,$m);
    $data[] = $m['1'];
    
    preg_match_all('|class="postTitle2"(.*?)</a>|i',$str,$m1);
    $data1[]=$m1['1'];
        
    $i=0;
    foreach ($data as $k=>$v){
        $i++;
        $content[$i]['count'] = $v;
    }
    
    $i=0;
    foreach ($data1 as $k=>$v){
        $i++;
        $content[$i]['content'] = $v;
    }
    
    echo "<pre>";
    print_r ($content);
    echo "</pre>";
    
    /* foreach ($content as $key=>$value){
        if($value['count'] >100){
            echo $value['content']."------------".$value['count']."<br>";
        }
    } */
    
}

?>

 

posted @ 2016-09-26 18:02  fleam  阅读(183)  评论(0编辑  收藏  举报