Quantcast
Channel: 質問!ITmedia 新着質問(Java/253)
Viewing all articles
Browse latest Browse all 2439

httpsサイトからのhtmlソース取得

$
0
0
以下のようなコードを書いてみましたところ、httpサイト (1) からはhtmlソースが全行取得できたのですが、httpsサイト (2) からは途中約1/3以降からしか得られませんでした。 ところが、httpsサイトでも (3) を試したところ全部取得できます。何がいけないのか~何を調べればよいのか~が分からず困惑しております。ご教示いただけましたら幸いです。 import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; import java.net.URL; import java.net.HttpURLConnection; import javax.net.ssl.HttpsURLConnection; public class GetHtmlTest { public static void main(String[] args) { try { URL u = new URL("http://stocks.finance.yahoo.co.jp/stocks/detail/?code=2371.T"); // (1) HttpURLConnection con = (HttpURLConnection) u.openConnection();// (1) InputStreamReader isr = new InputStreamReader(con.getInputStream(), "UTF-8");// (1) //URL u = new URL("https://www.sbisec.co.jp/ETGate");// (2) //HttpsURLConnection con = (HttpsURLConnection) u.openConnection();// (2) //InputStreamReader isr = new InputStreamReader(con.getInputStream(), "SJIS");// (2) //URL u = new URL("https://www.monex.co.jp/Login/00000000/login/ipan_web/hyoji");// (3) //HttpsURLConnection con = (HttpsURLConnection) u.openConnection();// (3) //InputStreamReader isr = new InputStreamReader(con.getInputStream(), "SJIS");// (3) BufferedReader br = new BufferedReader(isr); String line; StringBuilder sb = new StringBuilder(); while ((line = br.readLine()) != null) { sb.append(line).append(System.getProperty("line.separator")); } System.out.println(sb.toString()); br.close(); isr.close(); } catch (IOException e) { e.printStackTrace(); } } }

Viewing all articles
Browse latest Browse all 2439

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>