21,887
社区成员
发帖
与我相关
我的任务
分享
$conn[$k]=curl_init($url);
$header=$this->get_header($url,$this->ref[$k]);
curl_setopt($conn[$k],CURLOPT_HTTPHEADER,$header);
curl_setopt($conn[$k],CURLOPT_COOKIEFILE,$this->cookie);
curl_setopt($conn[$k],CURLOPT_RETURNTRANSFER,1);
curl_setopt($conn[$k],CURLOPT_TIMEOUT,$this->timeout);//timeout
//-----
function get_header($url,$ref,$method='GET')
{
$part=parse_url($url);
$path=$part[path];
if($method=='GET')
$path.='?'.$part[query];
$header=array();
$header[]= $path." HTTP/1.1";
$header[]= "Host: ".$part[host];
$header[]= "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322) ";
$header[]= "Accept: */* ";
$header[]= "Accept-Language: zh-cn";
$header[]= "Connection: Keep-Alive ";
if($ref)
$header[]= "Referer: ".$ref;
$header[]= "Accept-Encoding: gzip, deflate ";
//print_R($header);echo '<hr>';
return $header;
}