$code = implode('',file('http://www.csdn.net/Expert/topic/487/487624.shtm'));

解决方案 »

  1.   

    网页是php生成的,需要获得他的html,应该怎么办?急~~~~
      

  2.   

    给你这个试试!网页资料任你抓!哈哈!
    <? 
    class CKimoInfo { 
    var $datapath = "/data/kimo/"; //要暂存网页的位置 function GetdataPath(){ 
    $inc=getenv("document_root"); //unix绝对路径 
    return $inc.$this->datapath; 
    } function Kimoweather() { 
    $filename= $this->getdatapath()."ware.txt"; 
    $isf=is_file($filename); 
    // 该档案不存在,或是该档案超过一段时间后才更新
    if(!$isf || ($isf && (time()-filemtime($filename)) > (60*3)) ) { //档案超过3hour才更新 
    $kimofile="http://news.kimo.com.tw/"; //要抓取的目标网页 
    $fcontents = join( '', file( "$kimofile" ) ); 
    //分析你要的那一段 
    // 以本例: 我要抓介于<!-------x 和y -------之間的資料 
    $fcontents=ereg_replace("n","",$fcontents); 
    preg_match_all("|(<!-------------x 和y end---------------->)|", $fcontents, $out); 
    // 将多余不想要的字串过滤
    $out[0][0]=ereg_replace("/pic/","http://news.kimo.com.tw/pic/",$out[0][0]); 
    $out[0][0]=ereg_replace("x","",$out[0][0]); 
    // 存档 
    $fp = fopen ($filename, "w"); 
    fwrite ($fp,$out[0][0]); 
    fclose($fp); } 
    //以后每次只要直接将该档案的字串抓來用就好了 
    if(is_file($filename)) { 
    $fcontents = join( '', file( "$filename" ) ); 
    //echo $fcontents; 
    return $fcontents; 

    } } ?> 用法: 
    $kimo=new CKimoInfo(); 
    echo $kimo->Kimoweather(); 
      

  3.   

    写了一大堆,实际上还是用 file()函数
      

  4.   

    在你设计PHP页面时就不要用html,全部由php echo即可。
    我的做法是使用模板,解析后页面就放在一个字符串中,想输出还是想生成cache页面都很简单。
      

  5.   

    个人认为PHP/ASP/JSP中html嵌入代码的方式是一种很不好的习惯。
      

  6.   

    那你就别用php了,用perl吧……