如何使用nutch 1.2抓取特定URL

发布于 2024-11-29 09:22:20 字数 990 浏览 1 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

错々过的事 2024-12-06 09:22:20

我想我在某处读到过,这个配置是从上到下评估的。

并且由于

-. 

匹配所有内容 - nutch 将忽略进一步的条目。我的crawl-urlfilter.txt看起来像底部的那样(完全按照这个顺序)并且工作得很好:

# accept hosts in MY.DOMAIN.NAME
+^http://localhost:8080/

# skip everything else
-.

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:

# accept hosts in MY.DOMAIN.NAME
+^http://localhost:8080/

# skip everything else
-.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文