Windows下myeclipse 安裝 Nutch1.2(終於找到個不報錯的)

來源:互聯網
上載者:User
Windows下myeclipse 安裝 Nutch1.2(終於找到個不報錯的)

 

1.下載並安裝cygwin,安裝和環境配置不細說了。將%CYGWIN_HOME%\bin加到path中。 


2.匯入到Eclipse中 


①在Eclipse中添加File > New > Project > Java project。 

project name隨便,選擇 “Create project from existing source” ,在browse中選nutch的解壓路徑,如D:\nutch-1.2 


②在“Add Class Folder” 中選擇 conf 檔案夾。 


③然後再定義一個“Default ouput folder” ,名稱任意。注意不能選bin檔案夾,因為如果選了bin檔案夾做為Default output folder 編譯時間會清空該檔案夾,bin下的其他檔案會被刪掉,導致其他問題。 


④Finish. 


3.修改Nutch的設定檔,這裡以抓取www.163.com為例。 


①修改D:\nutch-1.2\conf下的nutch-site.xml配置

  1. <?xml version="1.0"?>
  2. <?xml-stylesheet href="configuration.xsl"?>
  3. <!-- Put site-specific property overrides in this file. -->
  4. <configuration>

  5. <property>
  6.   <name>http.agent.name</name>
  7.   <value>nutch-1.2</value>
  8.   <description>HTTP 'User-Agent'</description>
  9. </property>

  10. <property>
  11.   <name>searcher.dir</name>
  12.   <value>D:\nutch-1.2\crawl</value>
  13.   <description>Path to root of crawl.</description>
  14. </property>

  15. </configuration>

複製代碼

②修改在D:\nutch-1.2\conf下的crawl-urlfilter.txt

  1. # accept hosts in MY.DOMAIN.NAME
  2. +^http://([a-z0-9]*\.)*163.info/ 
  3. # skip everything else

複製代碼

③修改D:\nutch-1.2\conf下的nutch-default.xml

  1. <property>
  2.   <name>plugin.folders</name>
  3.   <value>./src/plugin</value>
  4.   <description>Directories where nutch plugins are located.  Each
  5.   element may be a relative or absolute path.  If absolute, it is used
  6.   as is.  If relative, it is searched for on the classpath.</description>
  7. </property>

複製代碼

④在D:\nutch-1.2\下,建立名為urls的檔案夾,並在檔案夾內建立url.txt的文本,寫入

  1. http://www.163.com/

複製代碼

4. 在Eclipse裡運行Nutch 


①Run-open run dialog 


②name隨便寫 


③在main class填寫

  1. org.apache.nutch.crawl.Crawl

複製代碼

④arguments填寫

  1. urls -dir crawl -depth 3 -topN 50

複製代碼

⑤在VM arguments填寫

  1. -Dhadoop.log.dir=logs -Dhadoop.log.file=hadoop.log

複製代碼

OK,運行,看Nutch在爬啊爬啊。

 

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.