ContentExtractor網(wǎng)頁正文抽取算法
簡介
ContentExtractor 是一個開源的網(wǎng)頁正文抽取工具,用JAVA實現(xiàn),具有非常高的抽取精度。
項目地址轉移
項目已和WebCollector合并,當前項目為老版本ContentExtractor,請前往WebCollector項目查看ContentExtractor的最新版本源碼和API。
教程(只適用于老版本,新版本請前往WebCollector)
ContentExtractor的接口非常簡單,用戶可以根據(jù)網(wǎng)頁的url,或者網(wǎng)頁的html,來進行網(wǎng)頁正文抽?。?/p>
根據(jù)url,抽取網(wǎng)頁的正文:
public static void main(String[] args) throws Exception {
String content=ContentExtractor.getContentByURL("http://news.
xinhuanet.com/world/2014-11/02/c_127166728.htm");
System.out.println(content);
}
根據(jù)html,抽取網(wǎng)頁的正文:
public static void main(String[] args) throws Exception {
String html="獲取到的html源碼";
String content=ContentExtractor.getContentByHtml(html);
System.out.println(content);
}
導入項目(只適用于老版本,新版本請前往WebCollector)
從ContentExtractor的github主頁https://github.com/hfut-dmic/ContentExtractor上下載ContentExtractor-{版本號}-bin.zip,將解壓后得到的jar包全部放到工程的build path即可。
ContentExtractor由合肥工業(yè)大學dmic團隊開發(fā)
Git@OSC:http://git.oschina.net/webcollector/ContentExtractor
評論
圖片
表情
