我正在尝试使用Java查找此页面的内容。
https://wordassociations.net/en/words-associated-with/cessation?button=Search
但是,我收到以下错误。我该如何解决呢?
线程“main”中的异常javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException:PKIX路径构建失败: sun.security.provider.certpath.SunCertPathBuilderException:无法 找到所请求目标的有效证书路径
/*
* SynonymFinder.java
*
*/
import java.net.URL;
import java.util.Scanner;
public class SynonymFinder {
public static void main(String[] args) throws Exception {
SynonymFinder obj = new SynonymFinder();
System.out.println(get("https://wordassociations.net/en/words-associated-with/cessation?button=Search"));
}
public static String get(String url) throws Exception {
StringBuilder sb = new StringBuilder();
for(Scanner sc = new Scanner(new URL(url).openStream()); sc.hasNext(); )
sb.append(sc.nextLine()).append('\n');
return sb.toString();
}
}
答案 0 :(得分:0)