需开启open_ssl扩展
function curl_string ($url,$user_agent,$proxy){
$ch = curl_init();
curl_setopt ($ch, CURLOPT_PROXY, $proxy);
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_AUTOREFERER, true);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt ($ch, CURLOPT_USERAGENT, $user_agent);
curl_setopt ($ch, CURLOPT_COOKIEJAR, "c:\\cookie.txt");
curl_setopt ($ch, CURLOPT_HEADER, 1);curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_TIMEOUT, 320);
$result = curl_exec ($ch);
curl_close($ch);
return $result;
}
$url_page = "https://www.google.com.hk/?gws_rd=cr";
//$url_page = "https://github.com/";
$user_agent = "Mozilla/4.0";
$proxy = "https://127.0.0.1:8087";
$string = curl_string($url_page,$user_agent,$proxy);
echo($string);// $string;
var_dump($string);
//echo file_get_contents("$url_page");
exit;