[問題] java爬網頁
爬網頁遇到一些問題
為什麼爬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會遇到這個問題
有什麼解決的方法呢???麻煩了
--
推
09/05 19:33,
09/05 19:33
推
09/05 19:34,
09/05 19:34
推
09/05 19:38,
09/05 19:38
推
09/05 19:39,
09/05 19:39
推
09/05 19:56,
09/05 19:56
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 163.13.225.58
※ 文章網址: https://www.ptt.cc/bbs/java/M.1447993062.A.45E.html
→
11/20 16:44, , 1F
11/20 16:44, 1F