【发布时间】:2017-06-26 08:19:22
【问题描述】:
我正在尝试使用 Nutch 2.3 和 HBase 0.94.14 抓取整个特定网站(忽略外部链接)。
我已经按照分步教程(可以找到它here)了解如何设置和使用这些工具。但是,我一直未能实现我的目标。 Nutch 不会抓取我在 seed.txt 文件中写入 URL 的整个网站,而是仅在第一轮中检索该基本 URL。为了让 Nutch 检索更多 URL,我需要运行进一步的爬网。
问题是我不知道我需要多少轮才能爬取整个网站,所以我需要一种方法来告诉 Nutch“继续爬取直到整个网站都被爬取完”(换句话说,“在一轮中抓取整个网站”)。
以下是我到目前为止所遵循的关键步骤和设置:
-
将基本 URL 放入 seed.txt 文件中。
http://www.whads.com/
-
设置 Nutch 的 nutch-site.xml 配置文件。完成本教程后,我根据其他 StackOverflow 问题的建议添加了一些属性(但是,它们似乎都没有为我解决问题)。
<?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <!-- Put site-specific property overrides in this file. --> <configuration> <property> <name>http.agent.name</name> <value>test-crawler</value> </property> <property> <name>storage.data.store.class</name> <value>org.apache.gora.hbase.store.HBaseStore</value> </property> <property> <name>plugin.includes</name> <value>protocol-httpclient|urlfilter-regex|index-(basic|more)|query-(basic|site|url|lang)|indexer-solr|nutch-extensionpoints|protocol-httpclient|urlfilter-regex|parse-(text|html|msexcel|msword|mspowerpoint|pdf)|summary-basic|scoring-opic|urlnormalizer-(pass|regex|basic)protocol-http|urlfilter-regex|parse-(html|tika|metatags)|index-(basic|anchor|more|metadata)</value> </property> <property> <name>db.ignore.external.links</name> <value>true</value> </property> <property> <name>db.ignore.internal.links</name> <value>false</value> </property> <property> <name>fetcher.max.crawl.delay</name> <value>-1</value> </property> <property> <name>fetcher.threads.per.queue</name> <value>50</value> <description></description> </property> <property> <name>generate.count.mode</name> <value>host</value> </property> <property> <name>generate.max.count</name> <value>-1</value> </property> </configuration>
-
根据 StackOverflow 和 Nutch 邮件列表中的建议,在 Nutch 的 regex-urlfilter.txt 配置文件中添加了“接受其他任何内容”规则。
# Already tried these two filters (one at a time, # and each one combined with the 'anything else' one) #+^http://www.whads.com #+^http://([a-z0-9]*.)*whads.com/ # accept anything else +.
-
抓取:我尝试过使用两种不同的方法(都产生相同的结果,第一轮只生成和获取一个 URL):
-
使用
bin/nutch(按照教程):bin/nutch inject urls bin/nutch generate -topN 50000 bin/nutch fetch -all bin/nutch parse -all bin/nutch updatedb -all -
使用
bin/crawl:bin/crawl urls whads 1
-
我还是错过了什么吗?难道我做错了什么?还是说 Nutch 不能一次性爬取整个网站?
非常感谢您!
【问题讨论】:
-
Nutch 抓取种子 URL 并从种子 URL 收集内链接和外链接,然后将这些链接添加到 Crawldb 以进行下一次抓取。我认为这就是为什么 nutch 没有一次抓取所有页面的原因
-
过时了,Nutch 2.3 不再有“深度”参数(实际上,bin/nutch crawl 已经完全弃用,而改用 bin/crawl)。这就是为什么我在问题中说出确切的版本。无论如何,感谢您抽出一些时间来回答!
标签: apache web-crawler nutch