Https下无法抓取只支持TLS1.2的站点
WebMagic默认的HttpClient只会用TLSv1去请求,对于某些只支持TLS1.2的站点(例如 https://juejin.im/) ,就会报错:
javax.net.ssl.SSLException: Received fatal alert: protocol_version
at sun.security.ssl.Alerts.getSSLException(Alerts.java:208)
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:1375)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:394)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:353)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:141)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
at us.codecraft.webmagic.downloader.HttpClientDownloader.download(HttpClientDownloader.java:85)
现在的修改方式是在HttpClientGenerator中构建SSLConnectionSocketFactory时加上支持。
更新会在0.7.4版本发布。
临时适配方式,修改HttpClientGenerator中的buildSSLConnectionSocketFactory方法,
return new SSLConnectionSocketFactory(createIgnoreVerifySSL(), new String[]{"SSLv3", "TLSv1", "TLSv1.1", "TLSv1.2"},
null,
new DefaultHostnameVerifier())
重写自己实现的HttpClientDownloader,并设置到Spider中。
= = 我也遇到这个问题了。
org.apache.http.conn.ssl.SSLConnectionSocketFactory - Enabled protocols: [TLSv1]
0.7.4到现在都还没发布??
0.7.4 还没有发布~
既然已经给方案了,大伙自己手动修改下呗。
@z201 怎么修改?
难受~~ 希望早日发布0.74版本
官方教程的第一个爬虫例子都出现这种情况,真是尴尬!
的确有点尬~第一次进来看,懵逼了。
的确有点尬~第一次进来看,懵逼了。
hhh,我也是,然后看到0.74版本至今还没面世,我在想还要不要继续用这个爬,这位兄台还在?
官方网站 真的是非常不稳定天天挂~还没学到一半 就挂了 3次。。
官方网站 真的是非常不稳定天天挂~还没学到一半 就挂了 3次。。
什么官方网站?
官方网站 真的是非常不稳定天天挂~还没学到一半 就挂了 3次。。
什么官方网站?
webmagic.io 这个网站 一天断N次。。
坐等 0.74
font{
line-height: 1.6;
}
ul,ol{
padding-left: 20px;
list-style-position: inside;
}
两年都没有更新了 已经不指望了。。。
Duncan
[email protected]
签名由
网易邮箱大师
定制
在2019年4月27日 17:44,alpaca<[email protected]> 写道:
坐等 0.74
—You are receiving this because you commented.Reply to this email directly, view it on GitHub, or mute the thread.
还是下载源码包 自己编译处理的
c
您好,按照您的方案我做出了修改后,在eclipse上运行成功,但在idea上运行依旧报错:Received fatal alert: protocol_version
master代码已经改了,只是mvn仓库的代码是老的,使用mvn报错,可以直接下载源码,重新打包,引入重新打的包
maven仓库的更新了吗
2020年都没更新0.74版本