需求:
需要采集页面的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");
?