java載入認證,訪問12306的https連結

來源:互聯網
上載者:User

標籤:java   認證   https   12306   

下載12306的認證,訪問12306網站,下載12306的認證

650) this.width=650;" src="http://www.weare.net.cn/EasyWeb/upload/image/20170106/1483689383822079610.jpg" title="1483689383822079610.jpg" alt="1111.jpg" style="border:0px;vertical-align:middle;height:auto;" />

匯出認證

650) this.width=650;" src="http://www.weare.net.cn/EasyWeb/upload/image/20170106/1483689408281051262.jpg" title="1483689408281051262.jpg" alt="2222.jpg" style="border:0px;vertical-align:middle;height:auto;" />

650) this.width=650;" src="http://www.weare.net.cn/EasyWeb/upload/image/20170106/1483689417663079312.jpg" title="1483689417663079312.jpg" alt="3333.jpg" style="border:0px;vertical-align:middle;height:auto;" />

匯出完成後,匯入認證

650) this.width=650;" src="http://www.weare.net.cn/EasyWeb/upload/image/20170106/1483689423450086371.jpg" title="1483689423450086371.jpg" alt="4444.jpg" style="border:0px;vertical-align:middle;height:auto;" />

查看是否匯入

650) this.width=650;" src="http://www.weare.net.cn/EasyWeb/upload/image/20170106/1483689431768003797.jpg" title="1483689431768003797.jpg" alt="5555.jpg" style="border:0px;vertical-align:middle;height:auto;" />

java中載入認證

public static void main( String[] args ){PrintWriter out = null;    BufferedReader in = null;    String result = "";    //設定認證    System.setProperty("javax.net.ssl.trustStore","D:\\Program Files\\Java\\jdk1.7.0_79\\bin\\12306d.keystore");      System.setProperty("javax.net.ssl.trustStorePassword", "12306java");      try {        URL realUrl = new URL("https://kyfw.12306.cn/otn/login/loginAysnSuggest");        // 開啟和URL之間的串連        URLConnection conn = realUrl.openConnection();        // 設定通用的請求屬性        conn.setRequestProperty("accept", "*/*");        conn.setRequestProperty("connection", "Keep-Alive");        conn.setRequestProperty("user-agent",                "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");        // 發送POST請求必須設定如下兩行        conn.setDoOutput(true);        conn.setDoInput(true);        // 擷取URLConnection對象對應的輸出資料流        out = new PrintWriter(conn.getOutputStream());        // 發送請求參數        out.print("loginUserDTO.user_name=aaa&userDTO.password=123456&randCode=182,51,19,130");        // flush輸出資料流的緩衝        out.flush();        // 定義BufferedReader輸入資料流來讀取URL的響應        in = new BufferedReader(                new InputStreamReader(conn.getInputStream()));        String line;        while ((line = in.readLine()) != null) {            result += line;        }        System.out.println(result);    } catch (Exception e) {        System.out.println("發送 POST 請求出現異常!"+e);        e.printStackTrace();    }    //使用finally塊來關閉輸出資料流、輸入資料流    finally{        try{            if(out!=null){                out.close();            }            if(in!=null){                in.close();            }        }        catch(IOException ex){            ex.printStackTrace();        }    }}


本文由微兒部落格原創,部落格地址:www.weare.net.cn 或者點擊 微兒部落格

java載入認證,訪問12306的https連結

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.