php curl 使用代理程序获取目标网页源码函数

2015/04/16 2671点热度 0人点赞 0条评论
//curl函数$file2 = GetSources($url2,$User_Agent,$Referer_Url);
function GetSources($Url,$User_Agent='',$Referer_Url='',$proxy)
{ 
$ch = curl_init(); 
curl_setopt ($ch, CURLOPT_PROXY, $proxy);
curl_setopt($ch, CURLOPT_TIMEOUT,5);
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,0);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); 
$MySources = curl_exec ($ch); 
curl_close($ch); 
return $MySources; 
}

幸运猪头

保持饥渴的专注,追求最佳的品质