About PHP using Curl to simulate login to the educational network
The system is used for queries, students can check their scores by replying to the number + password.
background:
Educational System: The educational system of the square (http://jwxt.tjtc.edu.cn/)
I found an entry without a verification code: http://jwxt.tjtc.edu.cn/default3.aspx
Now you need to log in through this portal to get student results.
The following code is now available:
This code basically can be simulated login to get students ' grades, schedules and so on.
But the content obtained through the test is null how can i solve it? Did something go wrong?
zfapi.php
function Get_td_array ($table) {
$table = Preg_replace ("'
]*?> ' si ', ' ", $table);
$table = Preg_replace ("'
]*?> ' si ', ' ", $table);
$table = Preg_replace ("'
]*?> ' si ', ' ", $table);
$table = Str_replace (""," {tr} ", $table);
$table = Str_replace (""," {td} ", $table);
Remove HTML Tags
$table = Preg_replace ("' <[/!") *? [^<>]*?> ' si ', ' ", $table);
Remove whitespace characters
$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;//School Number
private $password;//password
private $name;//Name
private $operate;//operation
Public $message = ';//return information
Public $url = ' http://jwxt.tjtc.edu.cn/';//Educational Network address
Public function __construct ($username, $password, $operate) {
$this->username = $username;
$this->password = $password;
$this->operate = $operate;
Log in first to facilitate the subsequent acquisition of data (as if there is a problem here)
$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 '://Personal Information inquiry
$this->prifile ();
Break
Case ' Dengji '://Grade Test query
$this->getdjks ();
Break
Case ' Chengji '://Score Query
$this->getchengji ();
Break
Case ' Kebiao '://Timetable Query
$this->getkb ();
Break
Case ' Bukao '://Retake Query
$this->getbukao ();
Break
}
return $this->message;
}
/**
* Access to personal information
*/
Private Function Prifile () {
$result = $this->simulated ($this->url. ' xsgrxx.aspx?xh= '. $this->username. ' &xm= '. $this->name. ' &gnmkdm=n121501 ');
Preg_match_all ('///', $result, $dataHeader);//1,0
Preg_match_all ('/
(. *) <\/span>/', $result, $dataValue);//2
$dataValue 1= 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 = $dataValue 1;
}
Private Function getKB () {//timetable
$result = $this->simulated ($this->url. ' xskbcx.aspx?xh= '. $this->username. ' &xm= '. $this->name. ' &gnmkdm=n121603 ');
Preg_match_all ('/
]*> ([\s\s]*?) <\/table>/', $result, $rs); $arr = Get_td_array ($rs [0][0]); for ($d =1; $d <=7; $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];