|
发表于 2015-12-9 15:39:25
|
显示全部楼层
湖北省武汉市
<?php
header("Content-Type:text/html;charset='UTF-8'");
class web_get{
public $url;
public $method=0;
public $postdata;
public $cookie;
public $return_cooke;
public $refer='';
public $outtime=60;
public $https=false;
private $ch;
public function __construct(){
define('_LOCAL_DIR', dirname(__FILE__).'/tmp');
if(!is_dir(_LOCAL_DIR)){
mkdir(_LOCAL_DIR);
}
define('_LOCAL_COOKIE_path', tempnam(_LOCAL_DIR,'cookie'));
$this->ch=curl_init();
}
public function __destruct(){
curl_close($this->ch);
}
public function _getweb(){
curl_setopt($this->ch,CURLOPT_URL,$this->url);
//curl_setopt($this->ch,CURLOPT_HEADER,1);//启用时会将头文件的信息作为数据流输出,可以看见文件头信息
curl_setopt($this->ch,CURLOPT_REFERER,$this->refer);
curl_setopt($this->ch,CURLOPT_TIMEOUT,$this->time);
curl_setopt($this->ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($this->ch,CURLOPT_COOKIE,$this->cookie);//提交cookie 多个之间加; 一个分号+一个空格
curl_setopt($this->ch,CURLOPT_COOKIEJAR,_LOCAL_COOKIE_path);//返回cookies作为文件保存
curl_setopt ( $this->ch, CURLOPT_SSL_VERIFYPEER, $this->https ); //https访问,禁用安全验证
curl_setopt($this->ch,CURLOPT_POST,1);//开启后 为POST
curl_setopt($this->ch,CURLOPT_POSTFIELDS,$this->data);//POST数据
$data=curl_exec($this->ch);
return $data;
}
}
$url=new web_get();
$return=$url->_getweb($url->url='https://aq.qq.com/cn2/unionverify/pc/pc_uv_choose',$url->method=1,$url->postdata='type=7',$url->cookie='css_ssid=6566169590; 3g_guest_id=-9102697348470898688; _ga=GA1.2.1466718128.1443167754;');
echo $return;
?>
|
|