【问题标题】:Why does Nutch (v2.3) crawl only the seed URL, instead of crawling an entire website?为什么 Nutch (v2.3) 只抓取种子 URL,而不是抓取整个网站?
【发布时间】:2017-06-26 08:19:22
【问题描述】:

我正在尝试使用 Nutch 2.3HBase 0.94.14 抓取整个特定网站(忽略外部链接)。

我已经按照分步教程(可以找到它here)了解如何设置和使用这些工具。但是,我一直未能实现我的目标。 Nutch 不会抓取我在 seed.txt 文件中写入 URL 的整个网站,而是仅在第一轮中检索该基本 URL。为了让 Nutch 检索更多 URL,我需要运行进一步的爬网。

问题是我不知道我需要多少轮才能爬取整个网站,所以我需要一种方法来告诉 Nutch“继续爬取直到整个网站都被爬取完”(换句话说,“在一轮中抓取整个网站”)。

以下是我到目前为止所遵循的关键步骤和设置:

  1. 将基本 URL 放入 seed.txt 文件中。

    http://www.whads.com/


  1. 设置 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>
    

  1. 根据 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
    +.
    

  1. 抓取:我尝试过使用两种不同的方法(都产生相同的结果,第一轮只生成和获取一个 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


【解决方案1】:

请更新您的配置,如下所示

    <property>
        <name>db.ignore.external.links</name>
        <value>false</value>
    </property>

实际上,您忽略了外部链接,即不抓取外部 URL

【讨论】:

  • 您误读或误解了我的问题,因为您的回答与我的问题完全无关。我确实想忽略外部链接。我的问题是 Nutch 不会一次性爬取整个网站,我将引用我的确切字面意思:“Nutch 不会爬取我在 seed.txt 文件中写入 URL 的整个网站,而是只检索该基础第一轮中的 URL。我需要运行进一步的爬网,以便 Nutch 检索更多的 URL”。我真的不知道你从我的问题中究竟从哪里提取了我需要 Nutch 来抓取外部链接的想法。
【解决方案2】:

在与 Nutch 玩了几天尝试了我在互联网上找到的所有东西之后,我最终放弃了。有人说,使用 Nutch 不再可能一次性抓取反反网站。 所以,如果有同样问题的人偶然发现这个问题,请像我一样做:放弃 Nutch 并使用 Scrapy (Python) 之类的东西。您需要手动设置蜘蛛,但它的工作原理就像一个魅力,可扩展性和速度更快,而且效果更好。

【讨论】:

    【解决方案3】:

    您是否尝试在最后使用 -1。我可以看到您最后使用 1 ,它只运行一次爬网。

    【讨论】:

    • 这不是问题的答案。请将其移至评论部分。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-25
    相关资源
    最近更新 更多