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

PHP代码 cpciti 1962℃
//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; 
}

转载请注明:我的个人学习笔记 » php curl 使用代理程序获取目标网页源码函数

喜欢 (0)