需求:
需要采集页面的title和keyword
实现:
依赖:
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.6.3</version>
</dependency>
代码:
Connection.Response response = connection.execute();
Map<String, String> headerMap= response.headers();
String body = response.body();
Document document = Jsoup.parse(body);
String title = document.head().select("title").text();
String keywords = document.head().select("meta[name=keywords]").attr("content");

本文介绍如何使用Java和Jsoup库来抓取网页的标题和关键词元信息。通过具体代码示例展示了依赖配置及抓取过程。
4154

被折叠的 条评论
为什么被折叠?



