`
小网客
  • 浏览: 1216878 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

基于Jsoup获取页面的header map,title和keywords

 
阅读更多

需求:

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

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics