我正在使用JTidy v。r938。我使用此代碼試圖清理網頁...如何讓JTIdy使HTML文檔格式正確?
final Tidy tidy = new Tidy();
tidy.setQuiet(false);
tidy.setShowWarnings(true);
tidy.setShowErrors(0);
tidy.setMakeClean(true);
Document document = tidy.parseDOM(conn.getInputStream(), null);
但是,當我分析這個網址 - http://www.chicagoreader.com/chicago/EventSearch?narrowByDate=This+Week&eventCategory=93922&keywords=&page=1,事情沒有得到清理。例如,在網頁上的META標籤,像
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
保持作爲
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
代替具有 「</META >」 標記或顯示爲 「< META HTTP-當量=」 內容-Type「content =」text/html; charset = UTF-8「/ >」。我通過輸出生成的JTidy org.w3c.dom.Document作爲字符串來確認。
我能做些什麼來使JTidy真正地清理頁面 - 即使它格式良好?我意識到還有其他工具,但這個問題具體涉及到使用JTIdy。
曾找到解決這個? –