Example #1
0
  /**
   * 体育查询系统的登陆操作, 登录成功返回Spider, 登录失败返回null
   *
   * @param stuNum - 学生学号
   * @param password - 密码
   * @return 登录成功返回Spider, 登录失败返回null
   */
  private Spider sportLogin(String stuNum, String password) {
    try {
      CloseableHttpClient client = HttpClients.createDefault();
      Spider spider = new Spider(client);
      spider.getGETContent(SportLoginPage);

      List<NameValuePair> loginForm = new ArrayList<NameValuePair>();
      loginForm.add(new BasicNameValuePair("username", stuNum));
      loginForm.add(new BasicNameValuePair("password", password));
      loginForm.add(new BasicNameValuePair("btnlogin.x", "31"));
      loginForm.add(new BasicNameValuePair("btnlogin.y", "6"));

      if (302 == spider.getPOSTCode(SportLoginAction, loginForm)) {
        return null;
      }

      return spider;
    } catch (Exception e) {
      e.printStackTrace();
      return null;
    }
  }
Example #2
0
  /**
   * 借书查询的登录操作, 登录成功返回Spider, 登录失败返回null
   *
   * @param stuNum - 学生学号
   * @param password - 密码
   * @throws ClientProtocolException
   * @throws IOException
   * @return 登录成功返回Spider, 登录失败返回null
   */
  private Spider libLogin(String stuNum, String password) {
    try {
      CloseableHttpClient client = HttpClients.createDefault();
      Spider spider = new Spider(client);
      spider.getGETContent(LibHome);

      List<NameValuePair> loginForm = new ArrayList<NameValuePair>();
      loginForm.add(new BasicNameValuePair("username", stuNum));
      loginForm.add(new BasicNameValuePair("password", password));
      loginForm.add(new BasicNameValuePair("backurl", "/uc/showPersonalSet.jspx"));
      loginForm.add(new BasicNameValuePair("schoolid", "482"));
      loginForm.add(new BasicNameValuePair("userType", "0"));

      if (302 != spider.getPOSTCode(LibLoginAction, loginForm)) {
        return null;
      }
      return spider;

    } catch (Exception e) {
      e.printStackTrace();
      return null;
    }
  }