• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

curl模拟登陆总是弹出验证码不正确

php 搞代码 3年前 (2022-01-23) 16次浏览 已收录 0个评论
文章目录[隐藏]

header(“Cont本文来源gaodai$ma#com搞$$代**码)网8搞代gaodaima码ent-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{
?>

<?php
}
?>

回复讨论(解决方案)

$url = 'http://jwc.wyu.edu.cn/student/';print_r(get_headers($url));

Array
(
[0] => HTTP/1.1 200 OK
[1] => Cache-Control: private
[2] => Connection: close
[3] => Date: Mon, 24 Aug 2015 11:30:29 GMT
[4] => Content-Length: 617
[5] => Content-Type: text/html
[6] => Set-Cookie: ASPSESSIONIDCQAATSAR=HGOCKONAKIMOPBIOFJFHPGFI; path=/
[7] => Server: IIS
[8] => X-Powered-By: WAF/2.0
[9] => Set-Cookie: safedog-flow-item=6BFDB3BC0A21C98B7224B81C2C04C934; expires=Mon, 24-Aug-2015 16:00:29 GMT; domain=wyu.edu.cn; path=/
)
访问主页就已经有 session 了,你读验证码时不带上是不行的

怎么带上session,在哪里带上

$url = 'http://jwc.wyu.edu.cn/student/';print_r(get_headers($url));

Array
(
[0] => HTTP/1.1 200 OK
[1] => Cache-Control: private
[2] => Connection: close
[3] => Date: Mon, 24 Aug 2015 11:30:29 GMT
[4] => Content-Length: 617
[5] => Content-Type: text/html
[6] => Set-Cookie: ASPSESSIONIDCQAATSAR=HGOCKONAKIMOPBIOFJFHPGFI; path=/
[7] => Server: IIS
[8] => X-Powered-By: WAF/2.0
[9] => Set-Cookie: safedog-flow-item=6BFDB3BC0A21C98B7224B81C2C04C934; expires=Mon, 24-Aug-2015 16:00:29 GMT; domain=wyu.edu.cn; path=/
)
访问主页就已经有 session 了,你读验证码时不带上是不行的

怎么带上 我学没多久,curl弄了很久了 如果可以能告诉下吗

$url = 'http://jwc.wyu.edu.cn/student/';print_r(get_headers($url));

Array
(
[0] => HTTP/1.1 200 OK
[1] => Cache-Control: private
[2] => Connection: close
[3] => Date: Mon, 24 Aug 2015 11:30:29 GMT
[4] => Content-Length: 617
[5] => Content-Type: text/html
[6] => Set-Cookie: ASPSESSIONIDCQAATSAR=HGOCKONAKIMOPBIOFJFHPGFI; path=/
[7] => Server: IIS
[8] => X-Powered-By: WAF/2.0
[9] => Set-Cookie: safedog-flow-item=6BFDB3BC0A21C98B7224B81C2C04C934; expires=Mon, 24-Aug-2015 16:00:29 GMT; domain=wyu.edu.cn; path=/
)
访问主页就已经有 session 了,你读验证码时不带上是不行的

可以用curl_setopt($ch,CURLOPT_HTTPHEADER,”Set-Cookie: ASPSESSIONIDCQAATSAR=HGOCKONAKIMOPBIOFJFHPGFI; path=/”);带上吗

$url = 'http://jwc.wyu.edu.cn/student/';print_r(get_headers($url));

Array
(
[0] => HTTP/1.1 200 OK
[1] => Cache-Control: private
[2] => Connection: close
[3] => Date: Mon, 24 Aug 2015 11:30:29 GMT
[4] => Content-Length: 617
[5] => Content-Type: text/html
[6] => Set-Cookie: ASPSESSIONIDCQAATSAR=HGOCKONAKIMOPBIOFJFHPGFI; path=/
[7] => Server: IIS
[8] => X-Powered-By: WAF/2.0
[9] => Set-Cookie: safedog-flow-item=6BFDB3BC0A21C98B7224B81C2C04C934; expires=Mon, 24-Aug-2015 16:00:29 GMT; domain=wyu.edu.cn; path=/
)
访问主页就已经有 session 了,你读验证码时不带上是不行的

非常感谢 我模拟登陆成功了


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:curl模拟登陆总是弹出验证码不正确

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址