作者e23882 (呆呆要不要買降有)
看板java
標題[問題] java爬網頁
時間Fri Nov 20 12:17:39 2015
爬網頁遇到一些問題
為什麼爬ptt網頁版他會跳出
SSLHandshakeException
我google了一下很多啊六都說是證書的問題應該是license吧
如果是因為沒有license那我要怎麼解決這個問題呢??
貼一下大部分遇到的錯誤訊息
at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1949)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:302)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387)
at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.
java:543)
at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.
java:409)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.
openConnection(DefaultClientConnectionOperator.java:177)
at org.apache.http.impl.conn.ManagedClientConnectionImpl.
open(ManagedClientConnectionImpl.java:304)
我是用這樣的方法去爬的
webcatch(String website,String filename) throws IOException
{
FileWriter fw=new FileWriter(filename);
BufferedWriter bw=new BufferedWriter(fw);
HttpClient httpclient =new DefaultHttpClient();
HttpGet httpget =new HttpGet(website);
HttpResponse response =httpclient.execute(httpget);
String responseString =EntityUtils.toString(response.getEntity());
if(response.getStatusLine().getStatusCode() == HttpStatus.SC_OK)
{
bw.write(responseString);
}
else
{
System.out.println(response.getStatusLine());
}
只有爬ptt會遇到這個問題
有什麼解決的方法呢???麻煩了
--
推 staminafish:我國中都全校前10名09/05 19:33
推 montes3388: 全校有10個人09/05 19:34
推 twdonny: 其中5個缺席09/05 19:38
推 montes3388: 4個資源斑09/05 19:39
推 a110002211: 1個鄉民09/05 19:56
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 163.13.225.58
※ 文章網址: https://www.ptt.cc/bbs/java/M.1447993062.A.45E.html