Javaバージョン1.8.0_121、I see a solution for Java 9 onlyフェッチデータのテキストはSourceForge.net
Description:
を投げるよう私の目標は、総ダウンロードなどSourceForge
プロジェクトに関する情報を取得することですプロジェクトの SourceForge
にはSourceForge Downloads Stats APIというAPIがあります。
私は簡単なプログラムを生のテキストとして見て、私はJSONとしてそれを必要としません。例えば
私はgettings情報についてApache OpenOfficeダウンロードと、より多くの午前 - > Link , you can try it to see
しかし、私は以下のエラーの原因Java
を使用してデータをフェッチすることはできません。私は他のウェブサイトとのコードをテストし、それはうまく動作しますが、この1つの理由は分かりません。
Error:
Exception in thread "main" javax.net.ssl.SSLHandshakeException: Received fatal a
lert: handshake_failure
at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
at sun.security.ssl.Alerts.getSSLException(Alerts.java:154)
at sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:2023)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1125)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:13
75)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387)
at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Abstra
ctDelegateHttpsURLConnection.java:185)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnectio
n.java:1546)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection
.java:1474)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLCon
nectionImpl.java:254)
at aaTester.URLReader.main(URLReader.java:13)
import java.net.*;
import java.io.*;
public class URLReader {
public static void main(String[] args) throws Exception {
//Create HttpURLConnection
HttpURLConnection httpcon = (HttpURLConnection) new URL(
"https://sourceforge.net/projects/openofficeorg.mirror/files/stats/json?start_date=2014-10-29&end_date=2014-11-04").openConnection();
//In case it might to the trick...
httpcon.addRequestProperty("User-Agent", "Mozilla/5.0");
//Read the inputstream
BufferedReader in = new BufferedReader(new InputStreamReader(httpcon.getInputStream()));
//Print everything
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
}
}
import java.net.*;
import java.io.*;
public class URLReader {
public static void main(String[] args) throws Exception {
//Create HttpURLConnection
HttpURLConnection httpcon = (HttpURLConnection) new URL(
"https://sourceforge.net/projects/openofficeorg.mirror/files/stats/json?start_date=2014-10-29&end_date=2014-11-04").openConnection();
//In case it might to the trick...
httpcon.addRequestProperty("User-Agent", "Mozilla/5.0");
//Read the inputstream
BufferedReader in = new BufferedReader(new InputStreamReader(httpcon.getInputStream()));
//Print everything
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
}
}
最後Java Code:
上記大幅に理解されるで溶液。
アンディの答えを使用しようとすると、同じエラーが発生します。
[そのサーバは明らかに256ビットAESを使用する暗号スイートしかサポートしていません](https://www.ssllabs.com/ssltest/analyze.html?d=sourceforge.net)と_Oracle_ Java(vice OpenJDK)はそのまま使用できます256ビットの対称暗号は使用できません。 j8の場合はhttp://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.htmlを参照するか、以前のバージョンのアーカイブ・セクションを試してください。 –
@ dave_thompson_085 O_Oうわー、私はそれを知りませんでした...対称暗号を使って例を挙げるなら、私は受け入れボタンを15回クリックします。 – GOXR3PLUS
@ dave_thompson_085私はポータブルな私のアプリケーションが必要です[ライブラリにjarファイルを追加したい]ので、私はhttp://stackoverflow.com/questions/1828775/how-to-handle-invalid-ssl-certificates-with- apache-httpclientしかし、私はそれを行うために完全なハックを参照してください...あなたが研究する正しい方法に私を指示してくれてありがとう:) – GOXR3PLUS