@@ -58,6 +58,22 @@ public void onFailure(Call call, IOException e) {
5858 @ Override
5959 public void onResponse (Call call , Response response ) throws IOException {
6060 String url = response .request ().url ().toString ();
61+ if ("https://mis.bjtu.edu.cn/home/" .equals (url )) {
62+ String body = response .body ().string ();
63+ Document doc = Jsoup .parse (body );
64+ Element name = doc .selectFirst (".name_right > h3 > a" );
65+ if (name == null ) {
66+ loginCallback .onFailure (1 );
67+ return ;
68+ }
69+ String nameStr = name .text ().split ("," )[0 ];
70+ Element id = doc .selectFirst (".name_right .nr_con span:contains(身份)" );
71+ String idStr = id .text ().replace ("身份:" , "" );
72+ Element department = doc .selectFirst (".name_right .nr_con span:contains(部门)" );
73+ String departmentStr = department .text ().replace ("部门:" , "" );
74+ loginCallback .onResponse (nameStr + ";" + idStr + ";" + departmentStr );
75+ return ;
76+ }
6177 Request ttRequest = new Request .Builder ()
6278 .url (url )
6379 .header ("Host" , "cas.bjtu.edu.cn" )
@@ -157,7 +173,7 @@ public void onResponse(Call call, Response response) throws IOException {
157173 String departmentStr = department .text ().replace ("部门:" , "" );
158174 loginCallback .onResponse (nameStr + ";" + idStr + ";" + departmentStr );
159175 } else {
160- loginCallback .onFailure (1 );
176+ loginCallback .onFailure (0 );
161177 }
162178 } finally {
163179 response .close ();
0 commit comments