<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    天 霽

    那天風大,搜搜的
    posts - 4, comments - 36, trackbacks - 1, articles - 1
      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

    nutch在Windows上的安裝 step by step

    Posted on 2006-10-18 19:52 天霽 閱讀(7306) 評論(4)  編輯  收藏 所屬分類: nutch

    ???nutch作為開源代碼,為熱愛搜索引擎的開發人員們提供了很好的學習平臺,0.8版本開始,采用了Hadoop作為自己的分布式文件系統,更是把nutch同其他開源搜索引擎的差距拉開。

    ???nutch的官方網站:http://lucene.apache.org/nutch/
    ???nutch的入門文章:http://lucene.apache.org/nutch/tutorial8.html

    ???以下詳細的介紹一下nutch0.8的安裝方法:

    一、環境:
    ??????1.操作系統:windowsXp,windows2000+
    ??????2.javaVM:java1.5.x,設置JAVA_HOME到環境變量
    ??????3.cygwin,當然這個不是必需的,只是nutch提供的腳本只能在shell環境下使用,所以使用cygwin來虛擬shell命令。
    ??????4.nutch版本:0.8
    ??????5.tomcat:5.0

    二、cygwin的安裝:

    ??????cygwin的安裝在NutchWindows中安裝之細解一文中有較為詳細的介紹,此處不再介紹安裝步驟,只介紹安裝后需要如何判斷是否能夠使用:在cygwin的安裝目錄下,查找x:\cygwin\cygwin\bin\sh.exe,存在此命令即可使用。
    ??????cygwin在刪除后會發現無法再次成功安裝的問題,可以通過注冊表內的查找功能,刪除所有包含cygwin內容的鍵值即可。

    三、nutch的安裝和配置:

    ??????1。從http://lucene.apache.org/nutch/release/下載0.8或更高的版本,解壓縮后,放置到cygwin的根目錄下,如圖:

    ?

    ?????圖中可以看到nutch目錄在cygwin的根目錄下。
    ?????
    ??? 2。在nutch/bin下,建立urls目錄,然后建立一個url.txt文件,在url.txt文件內寫入一個希望爬行的url,例如:www.sina.com.cn,目錄結構如圖:

    ?

    ?????
    ??????3。打開nutch\conf\crawl-urlfilter.txt文件,把MY.DOMAIN.NAME字符替換為url.txt內的url的域名,其實更簡單點,直接刪除MY.DOMAIN.NAME這幾個字就可以了,也就是說,只保存+^http://([a-z0-9]*\.)*這幾個字就可以了,表示所有http的網站都同意爬行。

    ??????4 。打開nutch\conf\conf/nutch-site.xml文件,在<configuration></configuration>內插入一下內容:

    <property>

    ? <name>http.agent.name</name>

    ? <value></value>

    ? <description>HTTP 'User-Agent' request header. MUST NOT be empty -

    ? please set this to a single word uniquely related to your organization.

    ?

    ? NOTE: You should also check other related properties:

    ?

    ???? http.robots.agents

    ???? http.agent.description

    ???? http.agent.url

    ???? http.agent.email

    ???? http.agent.version

    ?

    ? and set their values appropriately.

    ?

    ? </description>

    </property>

    ?

    <property>

    ? <name>http.agent.description</name>

    ? <value></value>

    ? <description>Further description of our bot- this text is used in

    ? the User-Agent header.? It appears in parenthesis after the agent name.

    ? </description>

    </property>

    ?

    <property>

    ? <name>http.agent.url</name>

    ? <value></value>

    ? <description>A URL to advertise in the User-Agent header.? This will

    ?? appear in parenthesis after the agent name. Custom dictates that this

    ?? should be a URL of a page explaining the purpose and behavior of this

    ?? crawler.

    ? </description>

    </property>

    ?

    <property>

    ? <name>http.agent.email</name>

    ? <value></value>

    ? <description>An email address to advertise in the HTTP 'From' request

    ?? header and User-Agent header. A good practice is to mangle this

    ?? address (e.g. 'info at example dot com') to avoid spamming.

    ? </description>

    </property>

    ?????把<name>XXX</name>之間的內容替換為其他字符,當然就算是不替換也無所謂,這里的設置,是因為nutch遵守了robots協議,在獲取response時,把自己的相關信息提交給被爬行的網站,以供識別。

    ???以上配置,是爬取intranet的配置方式。

    ????四、執行nutch

    ???由于配置nutch采用的是單獨網站的配置方式,所以執行上我們也采用的是單網查詢,全網查詢在以后的內容中介紹。

    ???先看一看nutch給出的命令:nutch crawl urls -dir crawl -depth 3 -topN 50
    ???crawl:通知nutch.jar,執行crawl的main方法。
    ???urls:存放需要爬行的url.txt文件的目錄,注意,這個名字需要和你的文件夾目錄相同,如果你的文件夾為search,那這里也應該改成search。
    ???-dir crawl:爬行后文件保存的位置,可以在nutch/bin目錄下找到。
    ???-depth 3:爬行次數,或者成為深度,不過還是覺得次數更貼切,建議測試時改為1。
    ???-topN 50:一個網站保存的最大頁面數。


    ??????執行命令的步驟:
    ??????1。進入cygwin界面。
    ??????2。使用cd命令,進入nutch\bin路徑下。
    ??????3。執行:sh nutch crawl urls -dir crawl -depth 3 -topN 50

    ???具體的爬行日志可以在nutch/logs目錄下看到,注意查找“INFO? fetcher.Fetcher - fetching http://XXXXXXX”這樣的內容,這里是抓去過程日志。

    ???五、查詢搜索:
    ???nutch提供了類似google、baidu的網頁頁面,在nutch壓縮包下找到nutch-0.8.war文件,放到tomcat/webapps目錄下,修改webapps/nutch/WEB-INF/classes/nutch-site.xml文件內容如下:

    <property>
    <name>searcher.dir</name>
    <value>E:\\software\\splider\\nutch\\nutch-0.8\\nutch-0.8\\crawl</value>

    </property>

    ???<value/>的內容是剛才爬行后的crawl目錄位置,提供給客戶端來查詢。

      配置完成后,啟動tomcat,輸入http://localhost:8080/nutch,輸入關鍵字,就會看到結果了,下圖是我抓去wap網站的測試結果:


    ???六、總結:
    ???ntuch提供了一個高效、開源、易操作的搜索引擎,內部有許多細微之處都是值得借鑒的,例如采用了hadoop的分布式文件系統,類似eclipse的插件技術,apache的httpclient來訪問網站,org.cyberneko.html得HtmlParse來解析頁面等等,在以后會逐個介紹。


    歡迎轉載,請注明出處!


    評論

    # re: nutch在Windows上的安裝 step by step  回復  更多評論   

    2006-10-18 20:16 by 壞男孩
    頂~~~
    圖片無法顯示啊

    # re: nutch在Windows上的安裝 step by step  回復  更多評論   

    2006-11-15 11:59 by help
    <property>
    <name>http.proxy.host</name>
    <value>?</value>
    <description></description>
    </property>
    <property>
    <name>http.proxy.port</name>
    <value>?</value>
    <description></description>
    </property>

    請問?號處 應該填什么呀!! 萬分感謝!

    # re: nutch在Windows上的安裝 step by step  回復  更多評論   

    2006-11-15 15:09 by 天霽[匿名]
    填什么都可以,這個是遵守robots協議所需的內容,一般來說是填寫你的公司或個人的一些信息,以方便被爬行網站來識別你的身份和與你聯系。

    # re: nutch在Windows上的安裝 step by step  回復  更多評論   

    2010-03-09 22:56 by 路人a
    如果我想search 100個 website urls.txt 要用什麼分開網址?
    主站蜘蛛池模板: 国产免费女女脚奴视频网| 国产免费AV片在线观看播放| 99视频有精品视频免费观看| 国产亚洲人成网站在线观看不卡| 美女视频免费看一区二区| 国产婷婷高清在线观看免费| 亚洲AV无码成人网站在线观看| 国产麻豆剧传媒精品国产免费| 亚洲精品又粗又大又爽A片| 女人被男人桶得好爽免费视频| 亚洲av永久无码精品网址| 国产免费卡一卡三卡乱码| 在线视频亚洲一区| 亚洲国产成人乱码精品女人久久久不卡 | 中文字幕 亚洲 有码 在线| 桃子视频在线观看高清免费完整| 亚洲av片不卡无码久久| 德国女人一级毛片免费| 香蕉视频在线观看免费| 久久亚洲AV永久无码精品| 久久青草免费91线频观看不卡| 久久精品国产亚洲AV香蕉| 日本在线高清免费爱做网站| 亚洲国产精品成人AV在线| 午夜亚洲福利在线老司机| 成人免费无码H在线观看不卡| 亚洲成在人天堂一区二区| 97在线观看永久免费视频| 蜜桃传媒一区二区亚洲AV| 亚洲小说区图片区另类春色| 永久免费在线观看视频| 亚洲无码一区二区三区| 亚洲乱亚洲乱少妇无码| 99热在线观看免费| 亚洲精品成a人在线观看夫| 成人午夜亚洲精品无码网站| 91嫩草免费国产永久入口| 看成年女人免费午夜视频| 久久综合九九亚洲一区| 香蕉视频在线观看免费国产婷婷| 久久免费香蕉视频|