<?php
function GetSources($Url,$User_Agent='',$Referer_Url='') //抓取页面
{
  $ch = curl_init();
  curl_setopt ($ch, CURLOPT_URL, $Url);
  curl_setopt ($ch, CURLOPT_USERAGENT, $User_Agent);
  curl_setopt ($ch, CURLOPT_REFERER, $Referer_Url);
  //curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
  curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
  $MySources = curl_exec ($ch);
  curl_close($ch);
  return $MySources;
}

//每10分钟 进行缓存一下
$cachefile = "/www/web/xxxx.cache"; //cache文件(绝对路径)
$pertime = 600;  //600秒 =10分钟
if(time() - @filemtime("$cachefile") >= $pertime) {
	$Url = "http://www.xxxxxxxx.com/xxxx.htm"; //要获取内容的也没
	$User_Agent = "Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1;+.NET+CLR+2.0.50727;+InfoPath.2;+MAXTHON+2.0)";
	$Referer_Url = 'http://xxxxx.cn/';
	$aaaa = GetSources($Url,$User_Agent,$Referer_Url);	
  file_put_contents($cachefile,$aaaa);
  echo $aaaa;
 }else{
  include $cachefile;
 }
?>