java---获取html中的标签name

 

1.需要下载Jsoup jar包

public final static void parseResume(String fileName) throws IOException {
// 获得document对象
Document document = Jsoup.parse(new File(fileName), "utf-8");
Elements images = document.body().select("ThreadGroup");
Elements rows = images.select("ThreadGroup[guiclass=ThreadGroupGui]");
Elements children=rows.get(0).children();
JSONObject js = new JSONObject();

for(Element child:children ){
//System.out.println(child.attr("name")+"\t"+child.text());
js.put(child.attr("name"),child.text());
}
System.out.println(js);
}

 

 

 

posted @ 2021-01-18 16:56  沫笙*  阅读(558)  评论(0编辑  收藏  举报