0

我正在尝试使用 java 1.8.0_221 获取网页的源代码。(支持 TLSv1.0、TLSv1.1、TLSv1.2)我试过 Jsoup、URLConnection、HttpURLConnection,它们都不起作用,同样的错误。谁能给我一些建议,谢谢!

html = Jsoup.connect("https://news.google.com/rss/search?q=vehicle").get().html();

error: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake

html = Jsoup.connect("https://spectrum.ieee.org/rss/energy/fulltext").get().html();

error: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?

4

1 回答 1

0

在我的浏览器中,

https://news.google.com/rss/search?q=vehicle

重定向到

https://news.google.com/rss/search?q=vehicle&hl=en-US&gl=US&ceid=US:en

也许您需要在代码中指定浏览器用户代理

于 2020-10-28T09:46:14.053 回答