1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
// Return the course table string Private function classresult ($ xh, $ pwd ){ Date_default_timezone_set ("PRC"); // Set the time zone $ ClassList = ""; // declare course table variables $ Cookie = $ this-> login ($ xh, $ pwd ); $ View = $ this-> getViewJs ($ cookie, $ xh); // verify that the password is correct // If the password is correct If (! Empty ($ view )){ $ Url = "http://jw.hzau.edu.cn/xskbcx.aspx? Xh = {$ xh }"; $ Result = curl_request ($ url, '', $ cookie); // saved cookies Preg_match_all ('/ $ Table = $ out [0] [0]; // Obtain the entire course table Preg_match_all ('/
([\ W \ W] *?) <\/Table>/', $ result, $ out );
([\ W \ W] *?) <\/Td>/', $ table, $ out ); $ Td = $ out [1]; $ Length = count ($ td ); // Obtain the course list For ($ I = 0; $ I <$ length; $ I ++ ){ $ Td [$ I] = str_replace (" "," ", $ Td [$ I]); $ Reg = "/{(.*)}/"; If (! Preg_match_all ($ reg, $ td [$ I], $ matches )){ Unset ($ td [$ I]); } } $ Td = array_values ($ td); // re-index the course list array $ TdLength = count ($ td ); For ($ I = 0; $ I <$ tdLength; $ I ++ ){ $ Td [$ I] = iconv ('gb2312', 'utf-8', $ td [$ I]); } // Convert the course list to an array Function converttoTable ($ table ){ $ List = array ( 'Sun' => array ( '1, 2' => '', '3, 4' => '', '5, 6' => '', '7, 8' => '', '9, 10' =>'' ), 'Mon' => array ( '1, 2' => '', '3, 4' => '', '5, 6' => '', '7, 8' => '', '9, 10' =>'' ), 'Tues' => array ( '1, 2' => '', '3, 4' => '', '5, 6' => '', '7, 8' => '', '9, 10' =>'' ), 'Wed' => array ( '1, 2' => '', '3, 4' => '', '5, 6' => '', '7, 8' => '', '9, 10' =>'' ), 'Thur' => array ( '1, 2' => '', '3, 4' => '', '5, 6' => '', '7, 8' => '', '9, 10' =>'' ), 'Fri' => array ( '1, 2' => '', '3, 4' => '', '5, 6' => '', '7, 8' => '', '9, 10' =>'' ), 'Sat '=> array ( '1, 2' => '', '3, 4' => '', '5, 6' => '', '7, 8' => '', '9, 10' =>'' ) ); $ Week = array ("sun" => "Sunday", "mon" => "Monday", "tues" => "Tuesday ", "wed" => "Wednesday", "thur" => "ththursday", "fri" => "Friday", "sat" => "Saturday "); $ Order = array ('1, 2', '3, 4', '5, 6', '7, 8', '9, 10 '); Foreach ($ table as $ key => $ value ){ $ Class = $ value; Foreach ($ week as $ key => $ weekDay ){ $ Pos = strpos ($ class, $ weekDay ); // Echo $ pos; If ($ pos ){ $ WeekArrayDay = $ key; // obtain the first-Dimensional key in the list array Foreach ($ order as $ key => $ orderClass ){ $ Pos = strpos ($ class, $ orderClass ); If ($ pos ){ $ WeekArrayOrder = $ orderClass; // The number of times the course is obtained Break; } } Break; } } $ List [$ weekArrayDay] [$ weekArrayOrder] = $ class; } Return $ list; } // Call a function Return converttoTable ($ td ); } Else { Return 0; } } |
6. try to query the empty classroom function. ?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
// Empty classroom query results Public function roomresult (){ $ Xh = ""; // Set the student ID $ Pwd = ""; // password corresponding to the student ID $ Cookie = $ this-> login ($ xh, $ pwd ); $ Url = "http://jw.hzau.edu.cn/xs_main.aspx? Xh = {$ xh }"; $ Result = curl_request ($ url, '', $ cookie); // saved cookies $ Url = "http://jw.hzau.edu.cn/xxjsjy.aspx? Xh = {$ xh }"; $ Post ['button2'] = iconv ('utf-8', 'gb2312', 'empty classroom query '); $ Post ['_ EVENTARGUMENT'] = ''; $ Post ['_ EVENTTARGET'] = ''; $ Post ['_ viewstate'] = $ this-> getViewJs ($ cookie, $ xh ); $ Post ['ddldsz'] = iconv ('utf-8', 'gb2312', 'Singles '); $ Post ['ddlsyxn '] = '1970-2014'; // academic year $ Post ['ddlsyxq'] = '1 '; $ Post ['jslb'] = ''; $ Post ['xiaoq'] = ''; $ Post ['kssj'] = $ _ GET ['start']; // start time of the submitted query $ Post ['sjd '] =_ _ GET ['class']; // submitted course times $ Post ['xn '] = '2014-2014'; // academic year $ Post ['xq'] = '2'; // term $ Post ['xqj'] = '6'; // The Day of the day of the week $ Post ['dpdatagrid1: txtPageSize '] = 90; // Number of Entries displayed per page $ Result = curl_request ($ url, $ post, $ cookie, 0 ); Preg_match_all ('/] +> [^>] + span>/', $ result, $ out ); $ Tip = iconv ('gb2312', 'utf-8', $ out [0] [3]); // Get the prompt content at the front of the page Preg_match_all ('/ ([\ W \ W] *?) <\/Table>/', $ result, $ out ); $ Table = iconv ('gb2312', 'utf-8', $ out [0] [0]); // Obtain the query list $ This-> load-> view ("classroom", array ('tip '=> $ tip, 'table' => $ table )); } |
In summary, the educational administration systems of every school are different. at this time, we can use firebug in Firefox to capture packets and see what we have submitted. The above is all the content of this article. I hope you will like it. This article describes how to use php to simulate login to the 正 system to capture information about the course schedule. For more information, see the next course... |