2019-09-06 23:53:10 +08:00

18 lines
558 B
PHP
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
function curlGet($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
//在http 请求头加入 gzip压缩
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept-Encoding: gzip'));
//curl返回的结果采用gzip解压
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
$output = curl_exec($ch);
curl_close($ch);
return $output;
}