標籤: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連結