【发布时间】:2018-06-04 22:13:42
【问题描述】:
我只想下载内容类型为“text/html”的网站,不下载 pdf/mp4/rar... 文件
现在我的代码是这样的:
Connection connection = Jsoup.connect(linkInfo.getLink()).followRedirects(false).validateTLSCertificates(false).userAgent(USER_AGENT);
Document htmlDocument = connection.get();
if (!connection.response().contentType().contains("text/html")) {
return;
}
有没有类似的东西:
Jsoup.connect(linkInfo.getLink()).contentTypeOnly("text/html");
【问题讨论】:
标签: java web-crawler jsoup