【问题标题】:configuring nutch regex-normalize.xml配置 nutch regex-normalize.xml
【发布时间】:2010-12-17 14:52:33
【问题描述】:

我正在使用基于 Java 的 Nutch 网络搜索软件。为了防止在我的搜索查询结果中返回重复的(url)结果,我试图在运行 Nutch 爬虫索引我的 Intranet 时从被索引的 url 中删除(又名规范化)“jsessionid”的表达式。但是,我对 $NUTCH_HOME/conf/regex-normalize.xml 的修改(在运行爬网之前)似乎没有任何效果。

  1. 如何确保我的 regex-normalize.xml 配置正在用于我的爬网?还有,

  2. 在抓取/索引期间,什么正则表达式会成功地从 url 中删除/规范化 'jsessionid' 的表达式?

以下是我当前的regex-normalize.xml的内容:

<?xml version="1.0"?>
<regex-normalize>
<regex>
 <pattern>(.*);jsessionid=(.*)$</pattern>
 <substitution>$1</substitution>
</regex>
<regex>
 <pattern>(.*);jsessionid=(.*)(\&amp;|\&amp;amp;)</pattern>
 <substitution>$1$3</substitution>
</regex>
<regex>
 <pattern>;jsessionid=(.*)</pattern>
 <substitution></substitution>
</regex>
</regex-normalize>

这是我为运行(测试)“爬网”而发出的命令:

bin/nutch crawl urls -dir /tmp/test/crawl_test -depth 3 -topN 500

【问题讨论】:

    标签: java lucene search-engine nutch web-crawler


    【解决方案1】:

    您使用的是哪个版本的 Nutch?我对 Nutch 不熟悉,但是 Nutch 1.0 的默认下载已经在 regex-normalize.xml 中包含了一个似乎可以解决这个问题的规则。

    <!-- removes session ids from urls (such as jsessionid and PHPSESSID) -->
    <regex>
      <pattern>([;_]?((?i)l|j|bv_)?((?i)sid|phpsessid|sessionid)=.*?)(\?|&amp;|#|$)</pattern>
      <substitution>$4</substitution>
    </regex>
    

    顺便说一句。 regex-urlfilter.txt 似乎也包含一些相关的东西

    # skip URLs containing certain characters as probable queries, etc.
    -[?*!@=]
    

    然后在 nutch-default.xml 中有一些你可能想要检查的设置

    urlnormalizer.order
    urlnormalizer.regex.file
    plugin.includes
    

    如果这一切都没有帮助,也许这样做:How can I force fetcher to use custom nutch-config?

    【讨论】:

    • 我使用的是 Nutch 0.8.1 版。此版本在 nutch-default.xml 中有以下设置: urlnormalizer.class ...而不是 urlnormalizer.order 我将值从 org.apache.nutch.net.BasicUrlNormalizer 更改为 org.apache.nutch.net.RegexUrlNormalizer。这就是导致 regex-normalize.xml 文件在爬网时实际参与的原因。此外,我在“plugin-includes”值中添加了以下插件: urlnormalizer-(pass|regex|basic) 默认情况下,0.8.1 版中不包含此插件。非常感谢您为我指明了正确的方向!
    • 没问题。现在考虑投票并接受我的回答
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多