java格式化读取html

走着路睡觉
  • java
  • html
小于 1 分钟

java格式化读取html

添加依赖

<dependency>
  <!-- jsoup HTML parser library @ https://jsoup.org/ -->
  <groupId>org.jsoup</groupId>
  <artifactId>jsoup</artifactId>
  <version>1.15.3</version>
</dependency>

代码

String html = "<html><head><title>First parse</title></head>"
  + "<body><p>Parsed HTML into a doc.</p></body></html>";
Document doc = Jsoup.parse(html);
Elements links = doc.select("a");
Element head = doc.select("head").first();

文档

https://jsoup.org/
上次编辑于:
贡献者: zhaojingbo
Loading...