开发者社区> 问答> 正文

关于用http client模拟登录教务系统的问题

response = httpclient.execute(httppost,context);
String result = response.getStatusLine().toString();
System.out.println(result);
HttpEntity entity1 = response.getEntity();
System.out.println(EntityUtils.toString(entity1));
Header locationHeader =response.getFirstHeader("location");

System.out.println(locationHeader.toString());
             String newuri = "http://jwxt1.cumt.edu.cn"+locationHeader.getValue(); 


         System.out.println(result);     
            HttpGet redirect=new HttpGet(newuri);  

            CloseableHttpResponse response1=httpclient.execute(redirect,context);  
            HttpEntity entity = response1.getEntity();
              System.out.println(EntityUtils.toString(entity)); 


            redirect.releaseConnection();  
返回的结果```
HTTP/1.1 302 Moved Temporarily
Object moved
Object moved to here.
Location: /xs_main.aspx?xh=我的学号

用httpclient模拟登陆学校的方正教务系统 post数据以后再获取重定向的地址进行get访问 为何不行

展开
收起
小旋风柴进 2016-03-13 14:51:39 2348 0
1 条回答
写回答
取消 提交回答
  • 第二次GET访问没有上传相关的COOKIE,导致服务器判断用户没有登录。

    2019-07-17 19:02:37
    赞同 展开评论 打赏
问答标签:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
阿里巴巴HTTP 2.0实践及无线通信协议的演进之路 立即下载
CDN助力企业网站进入HTTPS时代 立即下载
低代码开发师(初级)实战教程 立即下载