Posted on 2010-04-23 17:36
泰仔在線 閱讀(433)
評論(0) 編輯 收藏 所屬分類:
云計算相關
今天主要解決了Nutch中的一些小的問題,下面分別簡述一下。
1.網頁快照亂碼問題
Nutch的網頁快照是亂碼,解決辦法是修改tomcat/webapps/nutch目錄下的cached.jsp文件,修改其中的第63行。
原來的代碼是:content = new String(bean.getContent(details);
修改后的代碼是:content = new String(bean.getContent(details),"gb2312");
2.搜索結果高亮顯示
Nutch默認的搜索結果是沒有高亮的,解決辦法是在關鍵詞中加入html顏色標簽。
將 org.apache.nutch.searcher.Summary 第107行 代碼 修改為:
public String toString() {
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < fragments.size(); i++) {
buffer.append(fragments.get(i));
}
return "<span style='color:red'>" + buffer.toString()+ "</span>";
}
3.抓取頁面大小
Nutch默認只抓取一個頁面的前65k的內容,在我抓取bbs的時候,會出現只能抓取前幾個回帖的內容,所以想抓取整個頁面的內容,就要解除65k的限制。解決方法是修改nutch/conf中的nutch-site.xml文件,在文件最后添加以下內容:
<property>
<name>http.content.limit</name>
<value>-1</value>
<description>The length limit for downloaded content, in bytes.
If this value is nonnegative (>=0), content longer than it will be truncated;
otherwise, no truncation at all.
</description>
</property>
轉自:
實習日記(五)