<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.13.1</version>
</dependency>
public class JsoupTest {
public static void main(String[] args) throws Exception{
String html = "<html><head><title>First parse</title></head>"
+ "<body><p>Parsed HTML into a doc.</p><p>gewgewg</p></body></html>";
Document doc1 = Jsoup.parse(html);
doc1.getElementsByTag("p").forEach(e->System.out.println(e.text()));
Document doc2 = Jsoup.connect("https://www.oschina.net/search?scope=project&q=%E7%88%AC%E8%99%AB")
.data("query", "Java")
.userAgent("Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36")
.cookie("auth", "token")
.timeout(3000)
.get();
doc2.getElementsByClass("project-item").forEach(e->System.out.println(e.outerHtml()));
File input = new File("F:\\bak\\v2/websocket.html");
Document doc3 = Jsoup.parse(input, "UTF-8");
doc3.getElementsByTag("h1").forEach(e->System.out.println(e.outerHtml()));
}
}