htmunit模拟登录QQ邮箱的问题 10C

ptuiCB('4','0','','0','你输入的验证码不正确,请重新输入。', '');
但是页面是不需要输入验证码的。
或者说大神有其他思路提供以下也是可以的。

package com.hommsun.util;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.Set;

import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
import com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlDivision;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlPasswordInput;
import com.gargoylesoftware.htmlunit.html.HtmlTextInput;
import com.gargoylesoftware.htmlunit.util.Cookie;
public class mail {
public static void main(String[] args) throws FailingHttpStatusCodeException, MalformedURLException, IOException, InterruptedException {
WebClient webClients=new WebClient(BrowserVersion.CHROME);
webClients.getCookieManager().setCookiesEnabled(true);// 开启cookie管理
webClients.getOptions().setTimeout(90000);
webClients.getOptions().setCssEnabled(true);
webClients.getOptions().setJavaScriptEnabled(true);
webClients.setJavaScriptTimeout(40000);
webClients.getOptions().setRedirectEnabled(true);
webClients.getOptions().setThrowExceptionOnScriptError(false);
webClients.getOptions().setThrowExceptionOnFailingStatusCode(false);
webClients.setAjaxController(new NicelyResynchronizingAjaxController());
webClients.getOptions().setCssEnabled(false);
webClients.getOptions().setJavaScriptEnabled(true);

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

    HtmlPage pages= webClients.getPage("https://ssl.ptlogin2.qq.com/login?pt_vcode_v1=0&"
            + "pt_verifysession_v1=89de6f658a96ab2b8c2a6d23c771868ba45179d6f74b2c18f74950997dc9904ab0baeeffeed27455e98f2d1ee897ac1c0bafc3f6150ceae7&"
            + "verifycode=!SPH&u=1121212159&"
            + "p=QgLnLon9MTOuz40aq4QvjzpdT3wdOFTYJUNKrEUdNvXBaofej6u58q9VD2LkvX-BIcLrt2XabGkJEYXmF1LvCGCr6iJvvRO6i6t9ifgP3qXN-Udw*URwRRtnSdBuX*XKnVknsC3ZEIH8TmvhJy-SonNBPbnIxZGpRQ9WC-6ttNuunY8YRsvZyrfdVh9fE*jgdQo3FKXkyJYkfm2LGm7wwIJ7oZnfox8n2ZdggBIWcHFGGFF1QNm-EIULDNshuyyXSoOAAJWboZHEjdDKR8WkFcImQPHVEcBOZI48GoiVZiLA70w7B7aLNpvVBGK5XMgp*-Sdf68OAak6agy1t27bQg__"
            + "&"
            + "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(pages.asText());



}

}

1个回答

你可以自己写http请求,来模拟浏览器的行为 比如登录 分析好登录请求的地址、请求参数、请求头信息然后用这些信息做http请求

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐