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 parseLoginStep3(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.putHeader("Referer", "http://uam.ct10000.com/ct10000uam/login"); req.addObjservers( new AbstractProcessorObserver(util, WaringConstaint.ZGDX_4) { @Override public void afterRequest(SimpleObject context) { parseLoginStep3(context); } }); spider.addRequest(req); } } else { parseLoginStep4(context); } }
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); }