Class SuffixURLFilter
- All Implemented Interfaces:
Configurable,URLFilter,Pluggable
- property "urlfilter.suffix.file" in ./conf/nutch-default.xml, and
- attribute "file" in plugin.xml of this plugin
This filter can be configured to work in one of two modes:
- default to reject ('-'): in this mode, only URLs that match suffixes specified in the config file will be accepted, all other URLs will be rejected.
- default to accept ('+'): in this mode, only URLs that match suffixes specified in the config file will be rejected, all other URLs will be accepted.
The format of this config file is one URL suffix per line, with no preceding whitespace. Order, in which suffixes are specified, doesn't matter. Blank lines and comments (#) are allowed.
A single '+' or '-' sign not followed by any suffix must be used once, to signify the mode this plugin operates in. An optional single 'I' can be appended, to signify that suffix matches should be case-insensitive. The default, if not specified, is to use case-sensitive matches, i.e. suffix '.JPG' does not match '.jpg'.
NOTE: the format of this file is different from urlfilter-prefix, because that plugin doesn't support allowed/prohibited prefixes (only supports allowed prefixes). Please note that this plugin does not support regular expressions, it only accepts literal suffixes. I.e. a suffix "+*.jpg" is most probably wrong, you should use "+.jpg" instead.
Examples
Example 1
The configuration shown below will accept all URLs with '.html' or '.htm' suffixes (case-sensitive - '.HTML' or '.HTM' will be rejected), and prohibit all other suffixes.
# this is a comment # prohibit all unknown, case-sensitive matching - # collect only HTML files. .html .htm
Example 2
The configuration shown below will accept all URLs except common graphical formats.
# this is a comment # allow all unknown, case-insensitive matching +I # prohibited suffixes .gif .png .jpg .jpeg .bmp
-
Field Summary
Fields inherited from interface org.apache.nutch.net.URLFilter
X_POINT_ID -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionInterface for a filter that transforms a URL: it can pass the original URL through or "delete" the URL by returning nullgetConf()booleanbooleanstatic voidvoidreadConfiguration(Reader reader) voidsetConf(Configuration conf) voidsetFilterFromPath(boolean filterFromPath) voidsetIgnoreCase(boolean ignoreCase) voidsetModeAccept(boolean modeAccept)
-
Constructor Details
-
SuffixURLFilter
- Throws:
IOException
-
SuffixURLFilter
- Throws:
IOException
-
-
Method Details
-
filter
Description copied from interface:URLFilterInterface for a filter that transforms a URL: it can pass the original URL through or "delete" the URL by returning null -
readConfiguration
- Throws:
IOException
-
main
- Throws:
IOException
-
setConf
- Specified by:
setConfin interfaceConfigurable
-
getConf
- Specified by:
getConfin interfaceConfigurable
-
isModeAccept
public boolean isModeAccept() -
setModeAccept
public void setModeAccept(boolean modeAccept) -
isIgnoreCase
public boolean isIgnoreCase() -
setIgnoreCase
public void setIgnoreCase(boolean ignoreCase) -
setFilterFromPath
public void setFilterFromPath(boolean filterFromPath)
-