好久没写代码了,今天为了在看一本每周工作4小时的书时,为了方便,少点几次翻页,少看几次广告,随手写下十行代码,效果不错。for($i = 1;$i<34;$i++){ 
                $dest_url = "http://book.qq.com/s/book/0/13/13775/$i.shtml";
$src_content = CS_file_get_contents($dest_url);
$src_content = iconv("GBK","utf-8//IGNORE",$src_content);
preg_match_all("/ <div\s*id=\"content\"[^>]*>([\d\D]*)<\/div>/iU",$src_content,$arr_text);
$dest_cont = $arr_text[1][0];
preg_match_all("/<h1>([\d\D]*)<\/h1>/iU",$src_content,$arr_text);
$title = $arr_text[0][0];
echo "<div style = 'background-color:#ccc; border:1px solidred; padding:6px; font-size:14px; line-height:25px;'>$title <br/> $dest_cont</div>";
}

解决方案 »

  1.   

    试了,确实不错,哈哈不过你放出代码应该把CS_file_get_contents改了
      

  2.   


    CS_file_get_contents改file_get_contents就行了
      

  3.   

    CS_file_get_contents改成file_get_contents  LZ严重牛B
      

  4.   

    不好意思,用了一个自己的函数。
    请大家使用时把
    CS_file_get_contents改成file_get_contentsfor($i = 1;$i<34;$i++){ 
                    $dest_url = "http://book.qq.com/s/book/0/13/13775/$i.shtml";
            $src_content = file_get_contents($dest_url);
            $src_content = iconv("GBK","utf-8//IGNORE",$src_content);
            preg_match_all("/ <div\s*id=\"content\"[^>]*>([\d\D]*)<\/div>/iU",$src_content,$arr_text);
            $dest_cont = $arr_text[1][0];
            preg_match_all("/<h1>([\d\D]*)<\/h1>/iU",$src_content,$arr_text);
            $title = $arr_text[0][0];
            echo "<div style = 'background-color:#ccc; border:1px solidred; padding:6px; font-size:14px; line-height:25px;'>$title <br/> $dest_cont</div>";
        }
      

  5.   

    敬仰LZ,同样的技术,我为了上H网,写了个抓图的功能,您竟然写了个励志小说抓取,同样是程序员,您的境界太高了
      

  6.   

    凑个热闹。set_time_limit(0);
      

  7.   

    我只能说 LZ 我得到你的代码 却得不到你的思想
    你是为了少看点广告而写代码 这一点来说 已经超越了所有的同僚 
    我还见过一个国外的牛人 用代码不断弹出CD来哄小孩子睡觉