我正在使用基于Java的Nutch网络搜索软件。为了防止在我的搜索查询结果中返回重复(url)结果,我试图在运行Nutch爬虫以索引我的Intranet时从被索引的URL中删除(a.k.a. normalize)'jsessionid'的表达式。但是我对$ NUTCH_HOME / conf / regex-normalize.xml的修改(在运行我的爬网之前)似乎没有任何效果。
如何确保我的regex-normalize.xml配置用于抓取?和,
在抓取/索引期间,哪个正则表达式会从网址成功删除/规范化'jsessionid'的表达式?
以下是我当前的regex-normalize.xml的内容:
<?xml version="1.0"?>
<regex-normalize>
<regex>
<pattern>(.*);jsessionid=(.*)$</pattern>
<substitution>$1</substitution>
</regex>
<regex>
<pattern>(.*);jsessionid=(.*)(\&|\&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
答案 0 :(得分:3)
您使用的是哪种版本的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)=.*?)(\?|&|#|$)</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?