caoheike
caoheike
2017-07-26 05:09

java Htmlunit登录邮箱的问题

50
  • 邮箱
  • 验证码

WebClient webClient = new WebClient(BrowserVersion.INTERNET_EXPLORER);
webClient.getCookieManager().setCookiesEnabled(true);// 开启cookie管理
webClient.getOptions().setTimeout(90000);
webClient.getOptions().setCssEnabled(true);
webClient.getOptions().setJavaScriptEnabled(true);
webClient.setJavaScriptTimeout(40000);
webClient.getOptions().setRedirectEnabled(true);
webClient.getOptions().setThrowExceptionOnScriptError(false);
final List collectedAlerts = new ArrayList();
webClient.setAlertHandler(new CollectingAlertHandler(collectedAlerts));
// HtmlPage page= webClient.getPage("http://localhost");
// page.getElementById("test").click();
//

// System.out.println(collectedAlerts.get(0));
HtmlPage pageRsaInfo= webClient.getPage("https://ssl.ptlogin2.qq.com/check?pt_tea=2&uin=1603302725&appid=522005705&ptlang=2052&regmaster=&pt_uistyle=9&r=0.07655477741844985&pt_jstoken=1515144655");
String info=pageRsaInfo.asText();
String[] infoarry=info.split(",");
String xx=infoarry[2].replace("'","");

String code=infoarry[1].replace("'","");
String sess=infoarry[3].replace("'","");

String vecode=infoarry[0].replace("'","");
System.out.println(vecode+"-----");
System.out.println(code+"验证码");
HtmlPage page= webClient.getPage("https://ui.ptlogin2.qq.com/cgi-bin/login?style=9&appid=522005705&daid=4&s_url=https%3A%2F%2Fw.mail.qq.com%2Fcgi-bin%2Flogin%3Fvt%3Dpassport%26vm%3Dwsk%26delegate_url%3D%26f%3Dxhtml%26target%3D&hln_css=http%3A%2F%2Fmail.qq.com%2Fzh_CN%2Fhtmledition%2Fimages%2Flogo%2Fqqmail%2Fqqmail_logo_default_200h.png&low_login=1&hln_autologin=%E8%AE%B0%E4%BD%8F%E7%99%BB%E5%BD%95%E7%8A%B6%E6%80%81&pt_no_onekey=1");
String aa="\x00\x00\x00\x00\x5f\x90\x75\x45";

    System.out.println(aa.replace("\\", "\\")+"---");
    String pwd="caoheike";

    page.executeJavaScript(" alert($.Encryption.getEncryption('"+pwd+"','"+aa.replace("\\", "\\")+"','"+code+"') )").getJavaScriptResult();

   HtmlPage pageend= webClient.getPage("https://ssl.ptlogin2.qq.com/login?pt_vcode_v1=0&pt_verifysession_v1="+sess+"&verifycode="+code+"&u=1121212159&p="+collectedAlerts.get(0)+"&pt_randsalt=2&ptlang=2052&low_login_enable=1&low_login_hour=720&u1=https%3A%2F%2Fw.mail.qq.com%2Fcgi-bin%2Flogin%3Fvt%3Dpassport%26vm%3Dwsk%26delegate_url%3D%26f%3Dxhtml%26target%3D%26ss%3D1&from_ui=1&fp=loginerroralert&device=2&aid=522005705&daid=4&pt_3rd_aid=0&ptredirect=1&h=1&g=1&pt_uistyle=9&regmaster=&");



    System.out.println(pageend.asXml());

ptuiCB('22009','0','','0','对不起,你的号码登录异常,请使用

QQ手机版

扫描二维码安全登录。

(帮助反馈)

(22009)', '');

        有心人帮忙 复制这段代码看一下是什么问题 。可以执行,但需要hrmlunit 包

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答

为你推荐

换一换