Jsoup可以用来做Java爬虫。
参考文章:https://www.cnblogs.com/sam-uncle/p/10922366.html
引入
org.jsoup jsoup 1.12.1
完整代码
public static void main(String[] args) {
String html = "我是标题 ";
html += "";
html += " - ";
html += "
- 张三 "; html += "
- 李四 "; html += "
- 王五 "; html += "
- 赵六 "; html += "
- 田七 "; html += "
不用HttpClient也可以获取网页内容
public static void main(String[] args) {
try {
Document document = Jsoup.connect("https://www.baidu.com").get();
//获取本地页面
//Document document = Jsoup.parse(new File("d://1.html"), "utf-8");
System.out.println(document.text());
} catch (IOException e) {
e.printStackTrace();
}
}



