2016-12-02 296 views
0

我試圖從抓取的內容中獲取特定信息。隨着nutch將整個網站的文本全部放在一起,我很難獲得特定的內容。我想爲我在彈性搜索中編入索引的抓取文本內容添加分隔符。在nutch爬行內容中添加分隔符

例如,而從http://example.com/抓取數據的獲取elasticsearch索引的數據

 

Example Domain Example Domain This domain is established to be used for illustrative examples in documents. You may use this domain in examples without prior coordination or asking for permission. More information... 

我希望它是格式

 

Example Domain | Example Domain | This domain is established to be used for illustrative examples in documents. You may use this domain in examples without prior coordination or asking for permission. | More information... 

我們能否在Nutch的配置某處定義這個分隔符?

回答

0

基本上你想要的是將分隔的字段存儲在網頁的不同部分,例如在ecomerce網站中,您希望產品頁面在不同字段中具有價格,評分和說明。在Nutch 1.x中,這是通過編寫一個自定義插件來完成獲取內容的解析。

您的插件將需要實現HtmlParseFilter接口和IndexingFilter,然後在Solr/ES中定義字段/映射。

如果您要編寫自定義插件,請檢查headings插件,該插件允許您提取hN標籤。

另一種可能性是看看https://issues.apache.org/jira/browse/NUTCH-1870,它可以讓你指定你想要提取哪些內容來指定xpath表達式。

+0

謝謝。很有幫助 – vibhash

+0

很高興幫助! –