如何使用nutch 1.2抓取特定URL
我正在使用 nutch-1.2,但无法限制我的配置文件仅抓取给定的 url
我的crawl-urlfilter.txt 文件是
# Each non-comment, non-blank line contains a regular expression
# prefixed by '+' or '-'. The first matching pattern in the file
# determines whether a URL is included or ignored. If no pattern
# matches, the URL is ignored.
# skip file:, ftp:, & mailto: urls
-^(file|ftp|mailto):
# skip image and other suffixes we can't yet parse
-\.(gif|GIF|js|jpg|JPG|png|PNG|ico|ICO|css|sit|eps|wmf|zip|ppt|mpg|xls|gz|rpm|tgz|mov|MOV|exe|jpeg|JPEG|bmp|BMP)$
# skip URLs containing certain characters as probable queries, etc.
-[?*!@=]
# skip URLs with slash-delimited segment that repeats 3+ times, to break loops
-.*(/[^/]+)/[^/]+\1/[^/]+\1/
# accept hosts in MY.DOMAIN.NAME
-.*
+^http://([a-z0-9]*\.)abc.com/[0-9].*[a-z]*.html$
-^http://([a-z0-9]*\.)*abc.com/[-a-z/]*/$
-^http://([a-z0-9]*\.)*abc.com/[-a-z]*.php$
谢谢
I'm using nutch-1.2 but not able to restrict my config file to crawl only given urls
my crawl-urlfilter.txt file is
# Each non-comment, non-blank line contains a regular expression
# prefixed by '+' or '-'. The first matching pattern in the file
# determines whether a URL is included or ignored. If no pattern
# matches, the URL is ignored.
# skip file:, ftp:, & mailto: urls
-^(file|ftp|mailto):
# skip image and other suffixes we can't yet parse
-\.(gif|GIF|js|jpg|JPG|png|PNG|ico|ICO|css|sit|eps|wmf|zip|ppt|mpg|xls|gz|rpm|tgz|mov|MOV|exe|jpeg|JPEG|bmp|BMP)$
# skip URLs containing certain characters as probable queries, etc.
-[?*!@=]
# skip URLs with slash-delimited segment that repeats 3+ times, to break loops
-.*(/[^/]+)/[^/]+\1/[^/]+\1/
# accept hosts in MY.DOMAIN.NAME
-.*
+^http://([a-z0-9]*\.)abc.com/[0-9].*[a-z]*.html$
-^http://([a-z0-9]*\.)*abc.com/[-a-z/]*/$
-^http://([a-z0-9]*\.)*abc.com/[-a-z]*.php$
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想我在某处读到过,这个配置是从上到下评估的。
并且由于
匹配所有内容 - nutch 将忽略进一步的条目。我的crawl-urlfilter.txt看起来像底部的那样(完全按照这个顺序)并且工作得很好:
I thought that I read somewhere, that this config is evaluated from top to bottom.
And since the
matches everything - nutch will ignore the further entries. My crawl-urlfilter.txt looks something like that at the bottom (in exactly that order) and is working pretty well: