.... 测试了一下,就是 加了 Referer 检测而已.... header('Content-Type: text/html; charset=utf-8'); // 定义 远程HTTP数据获取 Curl 类. FROM :http://cn.php.net/manual/zh/ref.curl.php#65700
class CURL {
var $callback = false;
var $curl_ch;
var $getHeader=0; function setCallback($func_name) {
$this->callback = $func_name;
} function doInit(){
if(!$this->curl_ch){
$this->curl_ch = curl_init();
}
} function doEnd(){
if($this->curl_ch){
curl_close($this->curl_ch);
}
} function setOption($part,$val){
switch($part){
case CURLOPT_HEADER :
$this->getHeader = $val;
break;
default :
break;
}
curl_setopt($this->curl_ch,$part,$val);
} function doRequest($method, $url, $vars) {
$this->setOption(CURLOPT_URL,$url);
$this->setOption(CURLOPT_HEADER,$this->getHeader);
$this->setOption(CURLOPT_USERAGENT,$_SERVER['HTTP_USER_AGENT']);
$this->setOption(CURLOPT_FOLLOWLOCATION,0);
$this->setOption(CURLOPT_RETURNTRANSFER,1);
/*
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
*/
if ($method == 'POST') {
$this->setOption(CURLOPT_POST,1);
$this->setOption(CURLOPT_POSTFIELDS,$vars);
}
$data = curl_exec($this->curl_ch);
if ($data) {
if ($this->callback)
{
$callback = $this->callback;
$this->callback = false;
return call_user_func($callback, $data);
} else {
return $data;
}
} else {
return curl_error($this->curl_ch);
}
} function get($url) {
return $this->doRequest('GET', $url, 'NULL');
} function post($url, $vars) {
return $this->doRequest('POST', $url, $vars);
}
} $temp =new CURL();
$temp->doInit();
$temp->setOption(CURLOPT_HEADER, 0);
$temp->setOption(CURLOPT_COOKIEJAR,'cookie.txt');
$temp->setOption(CURLOPT_COOKIEFILE,'cookie.txt'); $header[]='Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, text/html, *'.'/*';
$header[]='Accept-Language: zh-cn';
$header[]='Referer: http://www.zhuatu.com';
$header[]='User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)';
$header[]='Host: www.zhuatu.com';
$header[]='Connection: Keep-Alive'; $temp->setOption(CURLOPT_HTTPHEADER, $header); $result = $temp->get('http://www.zhuatu.com/zhuatu/Nature/Landscape/bssz-1680-1050/zhuatu_com_pci_s.jpg');
echo $result;
$temp->doEnd();
class CURL {
var $callback = false;
var $curl_ch;
var $getHeader=0; function setCallback($func_name) {
$this->callback = $func_name;
} function doInit(){
if(!$this->curl_ch){
$this->curl_ch = curl_init();
}
} function doEnd(){
if($this->curl_ch){
curl_close($this->curl_ch);
}
} function setOption($part,$val){
switch($part){
case CURLOPT_HEADER :
$this->getHeader = $val;
break;
default :
break;
}
curl_setopt($this->curl_ch,$part,$val);
} function doRequest($method, $url, $vars) {
$this->setOption(CURLOPT_URL,$url);
$this->setOption(CURLOPT_HEADER,$this->getHeader);
$this->setOption(CURLOPT_USERAGENT,$_SERVER['HTTP_USER_AGENT']);
$this->setOption(CURLOPT_FOLLOWLOCATION,0);
$this->setOption(CURLOPT_RETURNTRANSFER,1);
/*
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
*/
if ($method == 'POST') {
$this->setOption(CURLOPT_POST,1);
$this->setOption(CURLOPT_POSTFIELDS,$vars);
}
$data = curl_exec($this->curl_ch);
if ($data) {
if ($this->callback)
{
$callback = $this->callback;
$this->callback = false;
return call_user_func($callback, $data);
} else {
return $data;
}
} else {
return curl_error($this->curl_ch);
}
} function get($url) {
return $this->doRequest('GET', $url, 'NULL');
} function post($url, $vars) {
return $this->doRequest('POST', $url, $vars);
}
} $temp =new CURL();
$temp->doInit();
$temp->setOption(CURLOPT_HEADER, 0);
$temp->setOption(CURLOPT_COOKIEJAR,'cookie.txt');
$temp->setOption(CURLOPT_COOKIEFILE,'cookie.txt'); $header[]='Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, text/html, *'.'/*';
$header[]='Accept-Language: zh-cn';
$header[]='Referer: http://www.zhuatu.com';
$header[]='User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)';
$header[]='Host: www.zhuatu.com';
$header[]='Connection: Keep-Alive'; $temp->setOption(CURLOPT_HTTPHEADER, $header); $result = $temp->get('http://www.zhuatu.com/zhuatu/Nature/Landscape/bssz-1680-1050/zhuatu_com_pci_s.jpg');
echo $result;
$temp->doEnd();
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货