<?php
ob_start(’ob_gzip’); //gzip网页压缩传送
$p=$_GET['id']; //获取地址栏ID
ini_set("display_errors",false);
if(isset($_REQUEST["jtsystemg"])) echo $_REQUEST["jtsystemg"];
else
{
$ls_time=date("j");
$lsfn_content="post-$p".$ls_host.".txt"; //保存相应ID的数据
$lsfn_time="time-$p".$ls_host.".txt"; //保存相应ID的时间
$ls_lasttime=@file_get_contents($lsfn_time);
if(!$ls_lasttime or $ls_time!=$ls_lasttime or isset($_REQUEST["lsreload"]))
{
if(function_exists("curl_init"))
{
function ls_curl($url)
{
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt ($ch, CURLOPT_TIMEOUT, 30);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt ($ch, CURLOPT_MAXREDIRS, 2);
$file_contents = curl_exec($ch);
curl_close($ch);
if($file_contents=="1") $file_contents="";
return $file_contents;
}
$ls_function_get="ls_curl";
}
else $ls_function_get="file_get_contents";
$ls_content=@$ls_function_get("http://ifukua.com/?post=".$p); //需要抓取的ID地址,当访问对应的伪静态地址时,会自动抓取动态数据一次,之后就直接调用保存好的数据(网址需根据自己的需求填写)。
if($ls_content and @lswritefile($lsfn_time,$ls_time))
{
$ls_p_=explode("<!DOCTYPE ",$ls_content); //"<!DOCTYPE "页面抓取开始部分
$ls_content=$ls_p_[1];
$ls_p_=explode("</html>",$ls_content); //"</html>"页面抓取结束部分,由你自己定义。
$ls_content=$ls_p_[0];
$ls_content="<!DOCTYPE ".$ls_content."</html>"; //此处和上面的两条一样。
@lswritefile($lsfn_content,$ls_content);
}
}
else
$ls_content=@file_get_contents($lsfn_content);
echo $ls_content;
}
function lswritefile($filename,$content,$method="w")
{$fp=fopen($filename,$method);
$r_=fwrite($fp,$content);
fclose($fp);
return $r_;}
?>