Jsoup Document的获取

从字符串获取

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

从网址简单获取

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

从网址获取

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

从文件获取

Document doc = Jsoup.parse(file, "UTF-8");
发布了18 篇原创文章 · 获赞 0 · 访问量 618

猜你喜欢

转载自blog.csdn.net/weixin_45792450/article/details/104102868
今日推荐