Rumah > Artikel > pembangunan bahagian belakang > curl模拟登陆总是弹出验证码不正确
header("Content-type: text/html; charset=gb2312");
$CookieFile=tempnam("./tmep","beast");
if(isset($_GET["img"])){
$url = 'http://jwc.wyu.edu.cn/student/rndnum.asp';//验证码code
$ch = curl_init($url);
curl_setopt($ch,CURLOPT_COOKIEJAR, $CookieFile);//把返回来的cookie信息保存在文件中
curl_exec($ch);
curl_close($ch);
exit();
}
if(isset($_POST['d'])){
$b=$_POST['d'];//验证码
$p="UserCode=3114002555&UserPwd=不告诉你&Validate=".$b."&Submit=提 交";
$ch = curl_init();
// 2. 设置选项,包括URL
$reffer = 'http://jwc.wyu.edu.cn/student/body.htm';
curl_setopt($ch, CURLOPT_REFERER, $reffer);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:39.0) Gecko/20100101 Firefox/39.0");
curl_setopt($ch,CURLOPT_URL, "http://jwc.wyu.edu.cn/student/logon.asp");
curl_setopt($ch,CURLOPT_COOKIEJAR, $CookieFile);
curl_setopt($ch,CURLOPT_COOKIEFILE, $CookieFile);//同时发送Cookie
curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch,CURLOPT_POST, 1);
curl_setopt($ch,CURLOPT_POSTFIELDS, $p);//提交查询信息
$s = curl_exec($ch);
curl_close($ch);
$ch = curl_init();
$reffer = 'http://jwc.wyu.edu.cn/student/body.htm';
curl_setopt($ch, CURLOPT_REFERER, $reffer);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:39.0) Gecko/20100101 Firefox/39.0");
curl_setopt($ch,CURLOPT_URL, "http://jwc.wyu.edu.cn/student/logon.asp");
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,true);
curl_setopt($ch,CURLOPT_COOKIEFILE, $CookieFile);//同时发送Cookie
curl_setopt($ch,CURLOPT_COOKIEJAR, $CookieFile);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch,CURLOPT_POST, 1);
curl_setopt($ch,CURLOPT_POSTFIELDS, $p);//提交查询信息
$bs = curl_exec($ch);
echo $bs;//输出结果
curl_close($ch);
}else{
?>
$url = 'http://jwc.wyu.edu.cn/student/';print_r(get_headers($url));Array
怎么带上session,在哪里带上
$url = 'http://jwc.wyu.edu.cn/student/';print_r(get_headers($url));Array
$url = 'http://jwc.wyu.edu.cn/student/';print_r(get_headers($url));Array
$url = 'http://jwc.wyu.edu.cn/student/';print_r(get_headers($url));Array