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));
(
[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));
(
[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));
(
[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));
(
[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 了,你读验证码时不带上是不行的
非常感谢 我模拟登陆成功了

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

Laravel使用其直观的闪存方法简化了处理临时会话数据。这非常适合在您的应用程序中显示简短的消息,警报或通知。 默认情况下,数据仅针对后续请求: $请求 -

PHP客户端URL(curl)扩展是开发人员的强大工具,可以与远程服务器和REST API无缝交互。通过利用Libcurl(备受尊敬的多协议文件传输库),PHP curl促进了有效的执行

PHP日志记录对于监视和调试Web应用程序以及捕获关键事件,错误和运行时行为至关重要。它为系统性能提供了宝贵的见解,有助于识别问题并支持更快的故障排除

Laravel 提供简洁的 HTTP 响应模拟语法,简化了 HTTP 交互测试。这种方法显着减少了代码冗余,同时使您的测试模拟更直观。 基本实现提供了多种响应类型快捷方式: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

您是否想为客户最紧迫的问题提供实时的即时解决方案? 实时聊天使您可以与客户进行实时对话,并立即解决他们的问题。它允许您为您的自定义提供更快的服务

文章讨论了PHP 5.3中引入的PHP中的晚期静态结合(LSB),从而允许静态方法的运行时分辨率调用以获得更灵活的继承。 LSB的实用应用和潜在的触摸
