我正在尝试开发一个应用程序,在其中我将为Nutch中的urls文件提供一组受限制的URL.我能够抓取这些网址,并通过从细分中读取数据来获取它们的内容.
我已经通过给出深度1来抓取,因为我不关心网页中的外链或链接.我只需要url文件中该网页的内容.
但执行此爬网需要时间.所以,建议我一种减少爬行时间和提高爬行速度的方法.我也不需要索引,因为我不关心搜索部分.
有没有人有关于如何加快爬行的建议?
获得速度的主要方面是配置nutch-site.xml
<property>
<name>fetcher.threads.per.queue</name>
<value>50</value>
<description></description>
</property>
Run Code Online (Sandbox Code Playgroud)
您可以在nutch-site.xml中扩展线程.增加fetcher.threads.per.host和fetcher.threads.fetch都会提高爬网速度.我注意到了极大的改进.增加这些时要小心.如果您没有硬件或连接来支持此增加的流量,则爬网中的错误数量会显着增加.
对我来说,这个属性对我帮助很大,因为缓慢的域会减慢所有的获取阶段:
<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>
Run Code Online (Sandbox Code Playgroud)
例如,如果您尊重 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>
Run Code Online (Sandbox Code Playgroud)
但是请不要触及 fetcher.threads.per.queue 属性,您将在黑名单中完成...这不是提高抓取速度的好解决方案...
| 归档时间: |
|
| 查看次数: |
5711 次 |
| 最近记录: |