1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21st 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 a timetable string Private Function Classresult ($xh, $pwd) { Date_default_timezone_set ("PRC"); Time zone settings $classList = "";//Declare the schedule variable $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]; Get the whole timetable Preg_match_all ('/
([\w\w]*?) <\/table>/', $result, $out);
([\w\w]*?) <\/td>/', $table, $out); $TD = $out [1]; $length = count ($TD); Get a list of courses 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 list of courses $tdLength = count ($TD); for ($i =0; $i < $tdLength; $i + +) { $TD [$i] = iconv (' GB2312 ', ' UTF-8 ', $td [$i]); } Convert a timetable into an array form function ConvertToTable ($table) { $list = Array ( ' Sun ' = Array ( ' + ' and ' ' 3,4 ' = ', ' 5,6 ' = ', ' 7,8 ' = ', ' 9,10 ' and ' = ' ), ' mon ' = = Array ( ' + ' and ' ' 3,4 ' = ', ' 5,6 ' = ', ' 7,8 ' = ', ' 9,10 ' and ' = ' ), ' Tues ' = Array ( ' + ' and ' ' 3,4 ' = ', ' 5,6 ' = ', ' 7,8 ' = ', ' 9,10 ' and ' = ' ), ' Wed ' = Array ( ' + ' and ' ' 3,4 ' = ', ' 5,6 ' = ', ' 7,8 ' = ', ' 9,10 ' and ' = ' ), ' Thur ' = Array ( ' + ' and ' ' 3,4 ' = ', ' 5,6 ' = ', ' 7,8 ' = ', ' 9,10 ' and ' = ' ), ' Fri ' = Array ( ' + ' and ' ' 3,4 ' = ', ' 5,6 ' = ', ' 7,8 ' = ', ' 9,10 ' and ' = ' ), ' sat ' = = Array ( ' + ' and ' ' 3,4 ' = ', ' 5,6 ' = ', ' 7,8 ' = ', ' 9,10 ' and ' = ' ) ); $week = Array ("Sun" = "Sunday", "mon" = "Monday", "tues" = "Tuesday", "Wed" = "Wednesday", "Thur" and "Thursday", "Fri" and "Friday", "sat" = > "Saturday"); $order = Array (' Up ', ' 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; Gets the first dimension key in the list array foreach ($order as $key = = $orderClass) { $pos = Strpos ($class, $orderClass); if ($pos) { $weekArrayOrder = $orderClass; Getting the course is the section Break } } Break } } $list [$weekArrayDay] [$weekArrayOrder] = $class; } return $list; } Calling functions Return converttotable ($TD); }else{ return 0; } } |
6, then try to check the function of empty classroom ?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21st 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 study number $pwd = ""; Number corresponding to the password $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 ', ' single '); $post [' ddlsyxn '] = ' 2014-2015 '; Year $post [' ddlsyxq '] = ' 1 '; $post [' jslb '] = '; $post [' xiaoq '] = '; $post [' KSSJ ']=$_get[' start ']; Start query time for submission $post [' SJD ']=$_get[' class '];//the course section submitted $post [' xn ']= ' 2014-2015 ';//school year $post [' Xq ']= ' 2 ';//semester in which $post [' Xqj ']= ' 6 ';//day of the week $post [' dpdatagrid1:txtpagesize ']=90;//shows the number of bars per page $result = Curl_request ($url, $post, $cookie, 0); Preg_match_all ('/ ]+>[^>]+span>/', $result, $out); $tip = Iconv (' gb2312 ', ' utf-8 ', $out [0][3]);//Get prompt content at the front of the page Preg_match_all ('/ ([\w\w]*?) <\/table>/', $result, $out); $table = Iconv (' gb2312 ', ' utf-8 ', $out [0][0]); Get a list of queries $this->load->view ("classroom", Array (' tip ' = = $tip, ' table ' = + $table)); } |
This is all summed up, each school's educational system is not the same, then we can use the Firebug Firefox browser to grasp the package to see exactly what was submitted. The above mentioned is the whole content of this article, I hope you can like. http://www.bkjia.com/PHPjc/1002346.html www.bkjia.com true http://www.bkjia.com/PHPjc/1002346.html techarticle PHP Implementation Simulation Landing founder's educational system crawl schedule This article mainly introduces the PHP implementation of the founder of the Senate teaching system to crawl the relevant information, the need for friends can refer to the following courses ... |