欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

关于php使用curl模拟登录教务网的有关问题

程序员文章站 2022-05-23 11:29:53
...
关于php使用curl模拟登录教务网的问题
该系统用于微信查询当中,学生可通过回复学号+密码查询自己的成绩。

背景:
教务系统:正方的教务系统(http://jwxt.tjtc.edu.cn/)
我找到了一个不用验证码的入口:http://jwxt.tjtc.edu.cn/default3.aspx

现在需要通过这个入口模拟登录,获取学生成绩。

目前已有如下代码:
这段代码基本上能够模拟登录从而获取学生的成绩、课表等等。
但是通过测试 获取到的内容都是null 请问如何解决?是不是哪里出问题了?

zfapi.php

function get_td_array($table) {
$table = preg_replace("'
]*?>'si","",$table);
$table = preg_replace("']*?>'si","",$table);
$table = preg_replace("'","{tr}",$table);
$table = str_replace("","{td}",$table);
//去掉 HTML 标记
$table = preg_replace("']*?>'si","",$table);
//去掉空白字符
$table = preg_replace("'([rn])[s]+'","",$table);
$table = preg_replace('/ /',"",$table);
$table = str_replace(" ","",$table);
$table = str_replace(" ","",$table);

$table = explode('{tr}', $table);
array_pop($table);
foreach ($table as $key=>$tr) {
$td = explode('{td}', $tr);
array_pop($td);
$td_array[] = $td;
}
return $td_array;
}
class SimulatedLogin {
private $username;//学号
private $password;//密码
private $name;//姓名
private $operate;//操作
public $message = '';//返回信息
public $url = 'http://jwxt.tjtc.edu.cn/';//教务网地址

public function __construct($username, $password, $operate) {
$this->username = $username;
$this->password = $password;
$this->operate = $operate;
//首先进行登陆, 方便后面获取数据(好像在这里出现问题)
$this->Simulated($this->url.'default3.aspx', TRUE, '__VIEWSTATE=%2FwEPDwUKMTg5NjY5MDM3OWRkSvPPSOtLv5y%2BuNo7W2Yge4y1bPI%3D&TextBox1='.$this->username.'&TextBox2='.$this->password.'&Button1=');
$this->getName();
}

public function returnJson() {
switch ($this->operate) {
case 'xinxi'://个人信息查询
$this->prifile();
break;
case 'dengji'://等级考试查询
$this->getDjks();
break;
case 'chengji'://成绩查询
$this->getchengji();
break;
case 'kebiao'://课表查询
$this->getKb();
break;
case 'bukao'://补考查询
$this->getbukao();
break;
}
return $this->message;
}

/**
* 获取个人信息
*/
private function prifile() {
$result = $this->Simulated($this->url.'xsgrxx.aspx?xh='.$this->username.'&xm='.$this->name.'&gnmkdm=N121501');
preg_match_all('/关于php使用curl模拟登录教务网的有关问题/', $result, $dataHeader);//1,0
preg_match_all('/(.*)/', $result, $dataValue);//2
$dataValue1= array('id'=>strip_tags($dataValue[0][1]),'name'=>strip_tags($dataValue[0][8]),'cid'=>strip_tags($dataValue[0][46]),'xi'=>strip_tags($dataValue[0][54]),'zhuan'=>strip_tags($dataValue[0][64]));
$this->message = $dataValue1;
}

private function getKb() {//课表
$result = $this->Simulated($this->url.'xskbcx.aspx?xh='.$this->username.'&xm='.$this->name.'&gnmkdm=N121603');
preg_match_all('/
]*?>'si","",$table);
$table = str_replace("
]*>([\s\S]*?)/',$result,$rs);
$arr = get_td_array($rs[0][0]);
for ($d=1;$d$shuzu[$d][1]=$arr[1][$d];
$shuzu[$d][2]=$arr[2][$d+1];
$shuzu[$d][3]=$arr[3][$d];
$shuzu[$d][4]=$arr[4][$d];
$shuzu[$d][5]=$arr[5][$d];
$shuzu[$d][6]=$arr[6][$d];
$shuzu[$d][7]=$arr[7][$d];
$shuzu[$d][8]=$arr[8][$d];
$shuzu[$d][9]=$arr[9][$d];
$shuzu[$d][10]=$arr[10][$d];
$shuzu[$d][11]=$arr[11][$d];
关于php使用curl模拟登录教务网的有关问题

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。

相关文章

相关视频


网友评论

文明上网理性发言,请遵守 新闻评论服务协议

我要评论
  • 关于php使用curl模拟登录教务网的有关问题
  • 专题推荐

    作者信息
    关于php使用curl模拟登录教务网的有关问题

    认证0级讲师

    推荐视频教程
  • 关于php使用curl模拟登录教务网的有关问题javascript初级视频教程
  • 关于php使用curl模拟登录教务网的有关问题jquery 基础视频教程
  • 视频教程分类