|
发表于 2017-12-24 11:23:03
|
显示全部楼层
广西壮族自治区南宁市
- -
function curl_request($url,$post='',$cookie='',$returnCookie=0,$ua='',$Referer='',$ip=''){
//url:访问的URL,$post:post数据(不填则为GET),$cookie:提交的$cookies,$returnCookie:是否返回$cookies,$ua伪造ua(可空),$Referer伪造提交地址(可空),$ip伪造提交ip(可空)
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
if($ua) {
curl_setopt($curl, CURLOPT_USERAGENT, $ua);//ua
}
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_AUTOREFERER, 1);
if($Referer) {
curl_setopt($curl, CURLOPT_REFERER, $Referer);//来源网站
}
if($ip) {
curl_setopt($curl, CURLOPT_HTTPHEADER, array('X-FORWARDED-FOR:'.$ip, 'CLIENT-IP:'.$ip));//伪造来源IP
}
if($post) {
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post));
}
if($cookie) {
curl_setopt($curl, CURLOPT_COOKIE, $cookie);
}
curl_setopt($curl, CURLOPT_HEADER, $returnCookie);
curl_setopt($curl, CURLOPT_TIMEOUT, 10);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($curl);
if (curl_errno($curl)) {
return curl_error($curl);
}
curl_close($curl);
if($returnCookie){
list($header, $body) = explode("\r\n\r\n", $data, 2);
preg_match_all("/Set\-Cookie:([^;]*);/", $header, $matches);
$info['cookie'] = substr($matches[1][0], 1);
$info['content'] = $body;
return $info;
}else{
return $data;
}
}这是curl 提交的函数参考参考吧,能帮你的只有这么多了。
|
评分
-
参与人数 1 | 荣誉 +1 |
收起
理由
|
笨潴
| + 1 |
热心帮助他人,荣誉+1,希望继续努力(*^__^*) 嘻嘻! |
查看全部评分
|