protected void ssoLogin1(SimpleObject context) { Request req1 = ContextUtil.getRequest(context); Integer scode = (Integer) req1.getExtra(Request.STATUS_CODE); if (HttpUtil.isMovedStatusCode(scode)) { HttpResponse resp = ContextUtil.getResponse(context); Header h1 = resp.getFirstHeader("Location"); String nexturl = h1.getValue(); if (nexturl == null) { logger.error("Error : No Redirect URL"); } else { Request req = new Request(nexturl); req.setCharset(UAM_CHAR_SET); req.addObjservers( new AbstractProcessorObserver(util, WaringConstaint.ZGDX_7) { @Override public void afterRequest(SimpleObject context) { ssoLogin1(context); } }); spider.addRequest(req); } } else { endSSOLogin(context); } }
protected void parseLoginPage(SimpleObject context, final String prefix, final String phone) { Request req1 = ContextUtil.getRequest(context); Integer scode = (Integer) req1.getExtra(Request.STATUS_CODE); // DebugUtil.printCookieData(ContextUtil.getCookieStore(context), null); if (HttpUtil.isMovedStatusCode(scode)) { HttpResponse resp = ContextUtil.getResponse(context); Header h1 = resp.getFirstHeader("Location"); String nexturl = h1.getValue(); if (nexturl == null) { logger.error("Error : No Redirect URL"); } else { nexturl = fixedFullUrl(nexturl); Request req = new Request(nexturl.replaceAll(" ", "%20")); req.setCharset(UAM_CHAR_SET); req.putHeader("Referer", "http://www.189.cn/dqmh/login/loginJT.jsp"); req.addObjservers( new AbstractProcessorObserver(util, WaringConstaint.ZGDX_2) { @Override public void afterRequest(SimpleObject context) { parseLoginPage(context, prefix, phone); } }); spider.addRequest(req); } } else { if (prefix != null) { // com.lkb.debug.DebugUtil.printCookieData(ContextUtil.getCookieStore(context), null); saveVerifyImage(context, prefix, phone); } else { parseLoginStep2(context); } } }
protected void parseLoginStep2(SimpleObject context) { String text = ContextUtil.getContent(context); if (text == null) { return; } String phone1 = phoneNo; String password1 = password; String n = StringUtil.subStr("strEnc(username,", ");", text).trim(); if (!StringUtils.isBlank(n)) { String[] stra = n.trim().replaceAll("\'", "").split(","); // pwd, digit, f, s phone1 = executeJsFunc("des/tel_com_des.js", "strEnc", phoneNo, stra[0], stra[1], stra[2]); password1 = executeJsFunc("des/tel_com_des.js", "strEnc", password, stra[0], stra[1], stra[2]); } Document doc = ContextUtil.getDocumentOfContent(context); Elements form = doc.select("form#c2000004"); Request req = new Request(fixedFullUrl(form.attr("action"))); req.setMethod("POST"); req.initNameValuePairs(12); req.addNameValuePairs("lt", form.select("input[name=lt]").attr("value")); req.addNameValuePairs("_eventId", "submit"); req.addNameValuePairs("forbidpass", "null"); req.addNameValuePairs("areaname", areaName); req.addNameValuePairs("password", password1); req.addNameValuePairs("authtype", "c2000004"); req.addNameValuePairs("customFileld01", customField1); req.addNameValuePairs("customFileld02", customField2); req.addNameValuePairs("forbidaccounts", "null"); req.addNameValuePairs("open_no", "c2000004"); req.addNameValuePairs("username", phone1); req.addNameValuePairs("randomId", authCode == null ? "" : authCode); req.setCharset(UAM_CHAR_SET); req.addObjservers( new AbstractProcessorObserver(util, WaringConstaint.ZGDX_3) { @Override public void afterRequest(SimpleObject context) { parseLoginStep3(context); } }); spider.addRequest(req); }
private void goLoginReq(final String prefix, final String phone) { setUniqueHttpAndHttpsProxy(); Request req = new Request(getOpenLoginPage()); // 重写向的url带有空格,需要转义,不允许自动重定向 req.putExtra("redirectsEnabled", false); req.setCharset(UAM_CHAR_SET); req.putHeader("Referer", "http://www.189.cn/dqmh/login/loginJT.jsp"); // Mozilla/5.0 (Windows NT 5.1; rv:28.0) Gecko/20100101 Firefox/28.0 req.addObjservers( new AbstractProcessorObserver(util, WaringConstaint.ZGDX_1) { @Override public void afterRequest(SimpleObject context) { /*logger.info("***********************************************************************"); DebugUtil.printCookieData(ContextUtil.getCookieStore(context), "uam.ct10000.com"); logger.info("***********************************************************************"); */ parseLoginPage(context, prefix, phone); } }); spider.addRequest(req); }