php模拟登陆正方教务管理系统(thinkPHP5.0)
还有两个隐藏的input输入框
就是说登陆的时候,必须把这两个值加在post请求中,否则也是无法登陆的,这两个值也是js随机生成的,所以也需要php获取后加在post请求中。
首先是获取验证码和su并提交
getsecertcode.php
<?php
function curl_request($url, $post = '', $referer = '')
{//$cookie='', $returnCookie=0,$curl = curl_init();curl_setopt($curl, CURLOPT_URL, $url);curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)');curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);curl_setopt($curl, CURLOPT_AUTOREFERER, 1);curl_setopt($curl, CURLOPT_HEADER, 1);curl_setopt($curl, CURLOPT_REFERER, "http://jwgl.fafu.edu.cn/default2.aspx");curl_setopt($curl, CURLOPT_TIMEOUT, 10);curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);if ($post) {curl_setopt($curl, CURLOPT_POST, 1);curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post));}if ($referer) {curl_setopt($curl, CURLOPT_REFERER, $referer);}$data = curl_exec($curl);curl_close($curl);return $data;
}
function getView()
{$url = 'http://jwgl.fafu.edu.cn/default2.aspx';$result = curl_request($url);if (empty($result)) {return array('status' => "0",'message' => "模拟登陆失败,网址可能以改变",);}preg_match('/Location: \/\((.*)\)/', $result, $temp);
// var_dump($temp);$pattern = '/<input type="hidden" name="__VIEWSTATE" value="(.*?)" \/>/is';preg_match_all($pattern, $result, $matches);
// var_dump($matches);$res[0] = $matches[1][0];$res[1] = $temp[1];$parttern = '/<input type="hidden" name="__VIEWSTATEGENERATOR" value="(.*?)" \/>/is';preg_match_all($parttern, $result, $matches);$res[2] = $matches[1][0];if (empty($res)) {return array('status' => "0",'message' => "获取随即参数或_VIEWSTATE失败",);}return array('status' => "1",'message' => $res,);
}
$temp = getView()['message'];
$ss = "文本框";
?>
<?phpvar_dump($temp);$url='http://jwgl.fafu.edu.cn/(' . $temp[1] . ')/CheckCode.aspx' ;echo '<img src='.$url.' \/>';
?>
<form action='http://z.cn/sample/moni/login' method='post'><?php echo $ss; ?>:<input type='text' name='serectCode'><input type='submit' value='提交' name='sub'><input type="hidden" name="data1" value="<?php echo $temp[0] ?>"><input type="hidden" name="data3" value="<?php echo $temp[1] ?>"><input type="hidden" name="data2" value="<?php echo $temp[2] ?>">
</form>
获取所有需要的值之后,就是像登陆验证url发送post请求了,首先利用fiddler找到登陆需要的参数
其中值为空的就以空字符串代替
login()
function login()
{$this->temp[0] = $_POST['serectCode'];$this->temp[1] = $_POST['data1'];$this->temp[2] = $_POST['data2'];$this->temp[3] = $_POST['data3'];var_dump($this->temp);$url = 'http://jwgl.fafu.edu.cn/('.$this->temp[3].')/default2.aspx';//$post['__VIEWSTATE'] = $this->temp[1];$post['__VIEWSTATEGENERATOR'] = $this->temp[2];$post['txtUserName'] = $this->sid;$post['TextBox2'] = $this->password;$post['Textbox1'] = '';$post['txtSecretCode'] = $this->temp[0];$post['lbLanguage'] = '';$post['hidPdrs'] = '';$post['hidsc'] = '';$post['RadioButtonList1'] = iconv('utf-8', 'gb2312', $this->identity);$post['Button1'] = '';//iconv('utf-8', 'gb2312', '登录');$result = $this->curl_request($url, $post);if (empty($result)) {return array('status' => "0",'message' => "模拟登陆失败",);}$url = 'http://jwgl.fafu.edu.cn/('.$this->temp[3].')/content.aspx ';$referer = 'http://jwgl.fafu.edu.cn/('.$this->temp[3].')/xs_main.aspx?xh=3166016076';$result = $this->curl_request($referer, '', $url);$result = iconv('gb2312', 'utf-8//IGNORE', $result);preg_match('/<span id=\"xhxm\">(.*)<\/span>/', $result, $name);if (empty($name)) {echo '得不到您的姓名';}var_dump($name);$this->getkebiao();
}
失败则返回null
此后一段时间内在登陆只要发送一个带有随机字符串和学号的post请求即可,不用再重新输入验证码(好长时间内都可以,不过第二天好像就不行了)
xh就是学号
getkebiao()
function getkebiao(){$post_m['xh'] = $this->sid;$post_m['xm'] = iconv('utf-8', 'gb2312', '');$post_m['gnmkdm'] = 'N121603';$temp_info = http_build_query($post_m);$referer = 'http://jwgl.fafu.edu.cn/('.$this->temp[3].')/xs_main.aspx?xh=' . $this->sid;$url = 'http://jwgl.fafu.edu.cn/('.$this->temp[3].')/xskbcx.aspx?' . $temp_info;$result = $this->curl_request($url, '', $referer);$result = iconv('gb2312', 'utf-8', $result);if (empty($result)) {return array('status' => "0",'message' => "得到课表信息失败",);}print_r($result);$pattern = '/<td align=\"Center\" rowspan=\"2\"( width=\"7%\"){0,1}>([^<]*?)<br>([^<]*?)<br>([^<]*?)<br>([^<]*?)<br>([^<]*?)<\/td>/';preg_match_all($pattern, $result, $mm);$info_tea_cou_a = array_combine($mm[2], $mm[5]);$pattern = '/<td align=\"Center\" rowspan=\"2\"( width=\"7%\"){0,1}>([^<]*?)<br>([^<]*?)<br>([^<]*?)<br>([^<]*?)<br>([^<]*?)<br>(<br><font color=\'red\'>.*?<\/font><br>){0,1}<br>([^<]*?)<br>([^<]*?)<br>([^<]*?)<br>([^<]*?)<br>([^<]*?)(<br><br><font color=\'red\'>.*?<\/font>){0,1}<\/td>/';preg_match_all($pattern, $result, $tt);$info_tea_cou_b = array_combine($tt[2], $tt[5]);$info_tea_cou_c = array_combine($tt[8], $tt[11]);$info_temp = array_merge($info_tea_cou_a, $info_tea_cou_b, $info_tea_cou_c);if (empty($info_temp)) {return array('status' => "0",'message' => "您的课表信息为空",);}return array('status' => "1",'message' => $info_temp,);
要把上面所有的 jwgl.fafu.edu.cn换成自己学校的网址
php模拟登陆正方教务管理系统(thinkPHP5.0)相关推荐
- python3爬取教务系统_python requests模拟登陆正方教务管理系统,并爬取成绩
最近模拟带账号登陆,查看了一些他人的博客,发现正方教务已经更新了,所以只能自己探索了. 登陆: 通过抓包,发现需要提交的值 需要值lt,这是个啥,其实他在访问登陆页面时就产生了 session=req ...
- python爬取学校教务管理系统_python requests模拟登陆正方教务管理系统,并爬取成绩...
最近模拟带账号登陆,查看了一些他人的博客,发现正方教务已经更新了,所以只能自己探索了. 登陆: 通过抓包,发现需要提交的值 需要值lt,这是个啥,其实他在访问登陆页面时就产生了 session=req ...
- java模拟登陆正方教务管理系统
学了java后想设计一个在线提交活动中心使用申请的web网站,但问题是学生身份的验证.开始时是设想每年爬取一次全校学生信息,但速度太慢了,而且学号的规律也不清楚.然后想到借用教务管理系统自带的验证功能 ...
- php模拟登陆,php实现模拟登陆正方教务系统
本文主要介绍通过php的curl库实现正方教务系统的登陆,由于正方教务系统每年可能会有一些更新,因此本文是针对2018年而言,所介绍一些模拟登陆正方的方法,希望能帮助到大家. 1.保存登陆界面的验证码 ...
- php模拟登陆正方教务系统(2018年)
php模拟登陆正方教务系统(2018年) 本文主要介绍通过php的curl库实现正方教务系统的登陆,由于正方教务系统每年可能会有一些更新,因此本文是针对2018年而言,所介绍一些模拟登陆正方的方法. ...
- java实现模拟登陆正方教务系统
java实现模拟登陆学校教务管理系统 全部代码总览 此版本无注释,请赏脸移步本人GitHub:https://github.com/1243418950/Jwgl import java.io.Buf ...
- Java--使用httpClient模拟登陆正方教务系统获取课表
最近形如课程格子与超表课程表应用如雨后春笋般涌现,他们自动获取课程表是怎么实现的呢.于是我用Java实现了一下模拟登陆正方教务系统获取课表的过程. 首先,我们先了解一下网站登录的原理:当我们输入学号, ...
- 模拟登录正方教务管理系统-JAVA实现
模拟登录正方教务管理系统 这款应用能够将正方教务管理系统上的英语四六级信息查询功能.期末考试安排信息查询功能.期末考试成绩信息查询功能.课程表信息查询功能.毕业设计信息查询功能.个人头像信息查询功能在 ...
- Android 模拟登陆正方教务系统
茂名职业技术学院官网新闻APP 这是一个使用jsoup爬取茂职院官网和正方教务系统信息的app. 采用viewpager+fragment+tablayout结构,支持下拉刷新和上拉加载. 主要功能有 ...
最新文章
- 单阶段6D对象姿势估计
- GNN与Transformer融合促进药物发现 | 2022几何图机器学习展望
- 科大讯飞ai研究院_科大讯飞1024开发者大会:让AI赋能行业数字化升级
- GPU Gems2 - 2 使用基于GPU几何体裁剪图的地形渲染(Terrain Rendering Using GPU-Based Geometry Clipmaps)
- cam350怎么看顶层_厉害的人是怎么分析问题的?(实操干货)
- 网络不稳定的原因_关键词排名波动原因,如何解决网站排名不稳定!
- testng 组_TestNG组
- 信息图形化探索:图形化简历
- Shell命令-搜索文件或目录之which、find
- RecycleView的普通适配器(另加RecycleView的格局格式)
- 美国白宫《国家人工智能研究发展战略计划》
- 《SEM长尾搜索营销策略解密》一一2.3 一个长尾周期倒下来,还有千千万万个站起来...
- 人生感悟:欲望适度则为利,欲望过度则为害
- 避免移动终端设备数据丢失的十个方法
- Hexo主题制作指南
- dhtml gantt所有配置_dhtmlx-gantt相关配置
- CrateDB三机三节点部署(Docker Overlay网络)
- VmwareTools工具安装
- 服装检索-DeepFashion
- 偶数乘2奇数乘3C语言,输入一个整数x,如果为偶数乘2,否则乘3,然后输出.C语言
热门文章
- 上一主题 下一主题 一个微信账号登陆信息提取软件,有人知道吗?
- 手机端mp4文件头前置检测,检测mp4视频文件头(moov box)是否在前面
- 微信公众号之渲染静态模板
- 三维触控测试软件,解读苹果3D touch三维触控技术
- harmonyos1.0.1,华为正式发布鸿蒙系统HarmonyOS 1.0
- 基于多线程技术和自定义消息编程实现Windows 9x异步串行通信
- 20道jQuery 常见的面试问题和答案
- TMS320C6678开发笔记---IBL编译与分析5
- python非技术面试题宝典
- 请检查ftp文件服务器是否开启,查看服务器是否开启ftp服务