Re: [問題] HTML PARSER出包了,還是我使用方法錯了?
用了HTMLCLEANER,可是出來的結果都是一樣
code:
public static void main(String args[]) throws IOException {
URL url = new URL("http://www.discuss.com.hk/archiver/");
HtmlCleaner cleaner = new HtmlCleaner();
TagNode nodes = cleaner.clean(url);
TagNode[] nodeArray = nodes.getElementsByName("ul", true)[0].getAllElements(false);
Map nodeMap = nodes.getElementsByName("ul", true)[0].getAttributes();
System.out.println(nodeMap);
for(int i = 0; i < nodeArray.length; i++) {
System.out.println(nodeArray[i].getText());
}
output:
{class=archiver_forumlist}
論壇資訊
最新消息
香港討論區 Android App (測試版) 意見收集
香港討論區 iPhone App ( ver. 1.2) 意見收集
會員教學及意見
(略N行N字)
吹水閒聊
吹水廣場
抓出來的確實是<ul class="archiver_forumlist">這個TAG的內容,可以少了很多..
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 116.49.240.161
推
06/15 14:26, , 1F
06/15 14:26, 1F
討論串 (同標題文章)