欲望永不止息 2016-03-01 12:30 采纳率: 0%
浏览 2041

httpclient 模拟登录邮箱

httpclient 模拟登录邮箱 登录邮箱

private static String USERNAME = "111111";
private static String PASSWORD = "222222";
private static String LOGINURL = "https://mail.qq.com";

public static void main(String[] args) 
{
    HttpClient httpClient = new HttpClient();

    PostMethod authpost = new PostMethod(LOGINURL);

    NameValuePair user = new NameValuePair("user",USERNAME);
    NameValuePair pwd = new NameValuePair("password",PASSWORD);
    NameValuePair username = new NameValuePair("username",USERNAME + "@qq.com");
    authpost.setRequestBody(new NameValuePair[]{user,pwd,username});
    int status = httpClient.executeMethod(authpost);
    System.out.println(authpost.getResponseBodyAsString());
    System.out.println(status);

            为什么登录不上去,是因为没有设置登录页面参数吗?
  • 写回答

4条回答

  • threenewbee 2016-03-01 12:33
    关注

    用fiddler看下,返回了什么,对照浏览器如何提交的分析你的问题。另外无论如何你的代码都不对,如果你希望登录成功,那么起码应该接收来自服务器的cookie,并且在以后的访问的时候带上,才能保持登录状态。

    评论

报告相同问题?

悬赏问题

  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?