Update: 导入 Jsoup 依赖
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
*.idea/
|
||||
target
|
||||
@@ -0,0 +1,23 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>cn.hezhaohui</groupId>
|
||||
<artifactId>fund-crawler</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<java.version>21</java.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- https://mvnrepository.com/artifact/org.jsoup/jsoup -->
|
||||
<dependency>
|
||||
<groupId>org.jsoup</groupId>
|
||||
<artifactId>jsoup</artifactId>
|
||||
<version>1.17.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,18 @@
|
||||
package cn.hezhaohui.fund;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
|
||||
public class Application {
|
||||
public static void main(String[] args) {
|
||||
String htmlString = "<html><head><title>My title</title></head>"
|
||||
+ "<body>Body content</body></html>";
|
||||
|
||||
Document doc = Jsoup.parse(htmlString);
|
||||
String title = doc.title();
|
||||
String body = doc.body().text();
|
||||
|
||||
System.out.printf("Title: %s%n", title);
|
||||
System.out.printf("Body: %s", body);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user