时间:2021-07-01 10:21:17 帮助过:6人阅读
function fcontents( $url, $timeout = 5, $referer = "" ){
$t = parse_url($url);
$ch = curl_init();
$header = array (
'User-Agent: Mozilla/5.0 (Windows NT 5.2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.1.1916.153 Safari/537.36','X-FORWARDED-FOR:154.135.25.15', 'CLIENT-IP:154.135.25.15'
);
$cookie_jar = dirname(__FILE__)."/jy.cookie";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_REFERER, "http://$t[host]/"); //构造来路
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_jar);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_jar);
curl_setopt($ch, CURLOPT_HEADER, 0);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}