php curl 获取 HTTPS

时间:2024-04-04 18:33:51
注意:谷歌的话开vpn可能才可以,*也不行
function getHTTPS($url) {
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  curl_setopt($ch, CURLOPT_HEADER, false);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_REFERER, $url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  $result = curl_exec($ch);
  curl_close($ch);
  return $result;
} $timeout=15;

curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)");
//curl_setopt($ch, CURLOPT_USERAGENT, 'googlebot');
//curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);