2011-02-02 64 views
3

我正在嘗試開發一個應用程序,在該應用程序中,我會給Nutch中的urls文件提供一組受限制的網址。我能夠抓取這些網址,並通過從網段讀取數據來獲取它們的內容。如何加快在Nutch中爬行

我已經通過給出深度1進行爬網,因爲我不關心網頁中的鏈接或鏈接。我只需要該網址在urls文件中的內容。

但是執行此爬網需要時間。所以,建議我減少抓取時間並提高抓取速度。我也不需要索引,因爲我不關心搜索部分。

有沒有人有關於如何加快抓取的建議?

+0

Arjun,這是我的網站,你刮!停止! – s29 2013-03-12 23:47:33

回答

6

您可以放大nutch-site.xml中的線程。增加fetcher.threads.per.host和fetcher.threads.fetch將提高抓取速度。我注意到大幅改進。增加這些時請謹慎使用。如果您沒有硬件或連接來支持此增加的流量,則抓取中的錯誤數量可能會顯着增加。

0

如果你不需要關注鏈接,我沒有理由使用Nutch。您可以簡單地獲取您的URL列表,並使用curl將它們與http客戶端庫或簡單腳本一起提取。

+0

是的,感謝您的意見。我以前使用PHP-multi curl完成了報廢,並且我成功地獲得了結果。但我面臨的問題是,需要花費時間來獲取網頁的內容。所以,考慮到可擴展性和速度,我想轉向nutch。 – 2011-02-14 05:19:54

7

用於獲取速度是配置的nutch-site.xml中

<property> 
<name>fetcher.threads.per.queue</name> 
    <value>50</value> 
    <description></description> 
</property> 
1

你好,我也有新的這種爬行但我useed一些方法我得到了一些不錯的成績可能它會你 我最主要的改變了我的nutch-site.xml中具有這些屬性

<property> 
    <name>fetcher.server.delay</name> 
    <value>0.5</value> 
<description>The number of seconds the fetcher will delay between 
    successive requests to the same server. Note that this might get 
    overriden by a Crawl-Delay from a robots.txt and is used ONLY if 
    fetcher.threads.per.queue is set to 1. 
</description> 

</property> 
<property> 
    <name>fetcher.threads.fetch</name> 
    <value>400</value> 
    <description>The number of FetcherThreads the fetcher should use. 
    This is also determines the maximum number of requests that are 
    made at once (each FetcherThread handles one connection).</description> 
</property> 


<property> 
    <name>fetcher.threads.per.host</name> 
    <value>25</value> 
    <description>This number is the maximum number of threads that 
    should be allowed to access a host at one time.</description> 
</property> 

好心提出了一些更多的選擇 感謝

0

我也有類似的問題,並能提高速度的 https://wiki.apache.org/nutch/OptimizingCrawls

它有什麼可以放慢您的抓取和你可以做些什麼來改善每個問題的有用信息的幫助。

不幸的是在我的情況下,我的隊列相當不平衡,不能請求太快到更大的隊列,否則我會被阻塞,所以我可能需要去集羣解決方案或TOR,然後再加快線程。

4

對於我來說,這個屬性幫了我這麼多,因爲一個緩慢的域名可以減慢所有的讀取階段:

<property> 
    <name>generate.max.count</name> 
    <value>50</value> 
    <description>The maximum number of urls in a single 
    fetchlist. -1 if unlimited. The urls are counted according 
    to the value of the parameter generator.count.mode. 
    </description> 
</property> 

例如,如果你尊重的robots.txt(默認行爲)和域爬行時間太長,延遲將是:fetcher.max.crawl.delay。隊列中的很多這個域將會減慢所有的獲取階段,所以最好限制generate.max.count。

您可以用同樣的方法添加此屬性限制的獲取階段的時間:

<property> 
    <name>fetcher.throughput.threshold.pages</name> 
    <value>1</value> 
    <description>The threshold of minimum pages per second. If the fetcher downloads less 
    pages per second than the configured threshold, the fetcher stops, preventing slow queue's 
    from stalling the throughput. This threshold must be an integer. This can be useful when 
    fetcher.timelimit.mins is hard to determine. The default value of -1 disables this check. 
    </description> 
</property> 

但是,請不要觸摸到fetcher.threads.per.queue屬性,您將在完成黑名單...這不是一個好的解決方案來提高抓取速度...