2016年7月27日 星期三

使用TagSoup提取html的文字

當使用android來提取epub檔的文字時, 本來採用tika的 EpubParser來處理
而EpubParser又是採用android(java) sdk內的
javax.xml.parsers
org.apache.harmony
等類別來處理

但發現有一些缺點:
1.當epub內的xhtml有錯誤時, 會停止工作, 導致html內部分內容無法提取
2.org.apache.harmony使用一些 native code (非java code) 這導致除錯及修改
原始碼相當困難.

後來找到另一個 library 叫 TagSoup
是基於Apache License, Version 2.0的自由軟體
(TagSoup is free and Open Source software. As of version 1.2, it is licensed under the Apache License, Version 2.0)

它會最大可能的提取所有文字, 即使html內有錯誤發生


網址
http://home.ccil.org/~cowan/tagsoup/


範例參考以下網址

Using TagSoup to extract text from HTML 


  © Blogger templates Psi by Ourblogtemplates.com 2008

Back to TOP