JSoup.connect抛出403错误,而apache.httpclient能够获取内容
2022-09-02 11:42:57
工作解决方案如下(感谢Angelo Neuschitzer提醒将其作为解决方案):
Document doc = Jsoup.connect(url).userAgent("Mozilla").get();
Elements links = doc.getElementsByTag(HTML.Tag.CITE.toString);
for (Element link : links) {
String linkText = link.text();
System.out.println(linkText);
}
因此,userAgent:)