Jsoup Document acquisition

Obtain from a string

String html = "<html><head><title>Java爬虫</title></head>"
				+ "<body>内容部分</body></html>";
Document doc = Jsoup.parse(html);

Simply get out of URL

Document doc = Jsoup.connect("http://example.com/").get();

Obtained from the website

Document doc = Jsoup.connect("http://example.com";)
				  .data("query", "Java")
				  .userAgent("Mozilla")
				  .cookie("auth", "token")
				  .timeout(3000)
				  .post();

Obtained from the file

Document doc = Jsoup.parse(file, "UTF-8");
Published 18 original articles · won praise 0 · Views 618

Guess you like

Origin blog.csdn.net/weixin_45792450/article/details/104102868