普通网友 2017-07-26 05:09 采纳率: 100%
浏览 1634
已结题

java Htmlunit登录邮箱的问题

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条回答

  • cloudyzhao 2017-07-26 06:44
    关注

    你登录的时候有异常 除了密码还需要授权 你用电脑登一下就知道了

    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题