Package org.apache.nutch.protocol.file
Class File
java.lang.Object
org.apache.nutch.protocol.file.File
- All Implemented Interfaces:
Configurable,Pluggable,Protocol
This class is a protocol plugin used for file: scheme. It creates
FileResponse object and gets the content of the url from it.
Configurable parameters are file.content.limit and
file.crawl.parent in nutch-default.xml defined under
"file properties" section.-
Field Summary
FieldsFields inherited from interface org.apache.nutch.protocol.Protocol
X_POINT_ID -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetConf()Get theConfigurationobjectgetProtocolOutput(Text url, CrawlDatum datum) Creates aFileResponseobject corresponding to the url and return aProtocolOutputobject as per the content receivedcrawlercommons.robots.BaseRobotRulesgetRobotRules(URL url, CrawlDatum datum, List<Content> robotsTxtContent) No robots parsing is done for file protocol.crawlercommons.robots.BaseRobotRulesgetRobotRules(Text url, CrawlDatum datum, List<Content> robotsTxtContent) No robots parsing is done for file protocol.static voidQuick way for running this class.voidsetConf(Configuration conf) Set theConfigurationobjectvoidsetMaxContentLength(int maxContentLength) Set the length after at which content is truncated.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.nutch.protocol.Protocol
resolveUrl
-
Field Details
-
LOG
protected static final org.slf4j.Logger LOG
-
-
Constructor Details
-
File
public File()
-
-
Method Details
-
setConf
Set theConfigurationobject- Specified by:
setConfin interfaceConfigurable
-
getConf
Get theConfigurationobject- Specified by:
getConfin interfaceConfigurable
-
setMaxContentLength
public void setMaxContentLength(int maxContentLength) Set the length after at which content is truncated.- Parameters:
maxContentLength- max content in bytes
-
getProtocolOutput
Creates aFileResponseobject corresponding to the url and return aProtocolOutputobject as per the content received- Specified by:
getProtocolOutputin interfaceProtocol- Parameters:
url- Text containing the urldatum- The CrawlDatum object corresponding to the url- Returns:
ProtocolOutputobject for the content of the file indicated by url
-
main
Quick way for running this class. Useful for debugging.- Parameters:
args- run with no args to print help- Throws:
Exception- if there is a fatal error running this class with the given input
-
getRobotRules
public crawlercommons.robots.BaseRobotRules getRobotRules(Text url, CrawlDatum datum, List<Content> robotsTxtContent) No robots parsing is done for file protocol. So this returns a set of empty rules which will allow every url.- Specified by:
getRobotRulesin interfaceProtocol- Parameters:
url- URL to checkdatum- page datumrobotsTxtContent- container to store responses when fetching the robots.txt file for debugging or archival purposes. Instead of a robots.txt file, it may include redirects or an error page (404, etc.). ResponseContentis appended to the passed list. If null is passed nothing is stored.- Returns:
- robot rules (specific for this URL or default), never null
-
getRobotRules
public crawlercommons.robots.BaseRobotRules getRobotRules(URL url, CrawlDatum datum, List<Content> robotsTxtContent) No robots parsing is done for file protocol. So this returns a set of empty rules which will allow every url.- Specified by:
getRobotRulesin interfaceProtocol- Parameters:
url- URL to checkdatum- page datumrobotsTxtContent- container to store responses when fetching the robots.txt file for debugging or archival purposes. Instead of a robots.txt file, it may include redirects or an error page (404, etc.). ResponseContentis appended to the passed list. If null is passed nothing is stored.- Returns:
- robot rules (specific for this URL or default), never null
-