Posted on 2010-04-23 17:36
泰仔在線 閱讀(438)
評論(0) 編輯 收藏 所屬分類:
云計(jì)算相關(guān)
今天主要解決了Nutch中的一些小的問題,下面分別簡述一下。
1.網(wǎng)頁快照亂碼問題
Nutch的網(wǎng)頁快照是亂碼,解決辦法是修改tomcat/webapps/nutch目錄下的cached.jsp文件,修改其中的第63行。
原來的代碼是:content = new String(bean.getContent(details);
修改后的代碼是:content = new String(bean.getContent(details),"gb2312");
2.搜索結(jié)果高亮顯示
Nutch默認(rèn)的搜索結(jié)果是沒有高亮的,解決辦法是在關(guān)鍵詞中加入html顏色標(biāo)簽。
將 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默認(rèn)只抓取一個(gè)頁面的前65k的內(nèi)容,在我抓取bbs的時(shí)候,會出現(xiàn)只能抓取前幾個(gè)回帖的內(nèi)容,所以想抓取整個(gè)頁面的內(nèi)容,就要解除65k的限制。解決方法是修改nutch/conf中的nutch-site.xml文件,在文件最后添加以下內(nèi)容:
<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>
轉(zhuǎn)自:
實(shí)習(xí)日記(五)