zoukankan      html  css  js  c++  java
  • 站立会议总结03

    验证网上的获取网页post和cookice的JAVA代码,

     

     
    List<Cookie> cookies;                      //保存获取的cookie  
    HttpClient client = new DefaultHttpClient();                   
    HttpResponse httpResponse;     
           
    [java] view
    plaincopy
    String uriAPI = "http://210.43.188.41/_data/index_LOGIN.aspx";  
    [java] view
    plaincopy
    /* 建立HTTP Post连线 */  
    HttpPost httpRequest = new HttpPost(uriAPI);  
    List<NameValuePair> params = new ArrayList<NameValuePair>();  
    [java] view
    plaincopy
      
    params.add(new BasicNameValuePair("PassWord", "*****");   //这里的密码我用*取代了  
    params.add(new BasicNameValuePair("UserID", "201150080223");    //这是学号  
    params.add(new BasicNameValuePair("Sel_Type", "STU"));    //以学生身份登录  
    [java] view
    plaincopy
    try {  
        // 发出HTTP request  
        httpRequest.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));  
        // 取得HTTP response  
        httpResponse = client.execute(httpRequest);   //执行  
        // 若状态码为200 ok  
        if (httpResponse.getStatusLine().getStatusCode() == 200) {   //返回值正常  
            // 获取返回的cookie  
            cookies = ((AbstractHttpClient) client).getCookieStore().getCookies();  
        } else {  
        }  
    } catch (Exception e) {  
        e.printStackTrace();  
    }  
    

      

  • 相关阅读:
    apscheduler 踩坑
    fastapi 导出excel文件
    python flask 使用日志
    git 头指针游离问题
    C# 连接mysql填坑
    前端项目proxy小问题
    需完善--日志框架
    依赖<dependency>的scope了解
    git 退回到指定tag版本
    git切换远程仓库地址
  • 原文地址:https://www.cnblogs.com/helloalbert/p/4504701.html
Copyright © 2011-2022 走看看