DESCRIPTION

This module parses /robots.txt files as specified in "A Standard for Robot Exclusion", at <http://www.robotstxt.org/wc/norobots.html> Webmasters can use the /robots.txt file to forbid conforming robots from accessing parts of their web site.

The parsed files are kept in a WWW::RobotRules object, and this object provides methods to check if access to a given URL is prohibited. The same WWW::RobotRules object can be used for one or more parsed /robots.txt files on any number of hosts.

The following methods are provided:

$rules = WWW::RobotRules->new($robot_name)

This is the constructor for WWW::RobotRules objects. The first argument given to new() is the name of the robot.

$rules->parse($robot_txt_url, $content, $fresh_until)

The parse() method takes as arguments the URL that was used to retrieve the /robots.txt file, and the contents of the file.

$rules->allowed($uri)

Returns TRUE if this robot is allowed to retrieve this URL.

$rules->agent([$name])

Get/set the agent name. NOTE: Changing the agent name will clear the robots.txt rules and expire times out of the cache.

ROBOTS.TXT

The format and semantics of the "/robots.txt" file are as follows (this is an edited abstract of <http://www.robotstxt.org/wc/norobots.html> ):

The file consists of one or more records separated by one or more blank lines. Each record contains lines of the form

<field-name>: <value>

The field name is case insensitive. Text after the '#' character on a line is ignored during parsing. This is used for comments. The following <field-names> can be used:

User-Agent

The value of this field is the name of the robot the record is describing access policy for. If more than one User-Agent field is present the record describes an identical access policy for more than one robot. At least one field needs to be present per record. If the value is '*', the record describes the default access policy for any robot that has not not matched any of the other records.

Disallow

The value of this field specifies a partial URL that is not to be visited. This can be a full path, or a partial path; any URL that starts with this value will not be retrieved

ROBOTS.TXT EXAMPLES

The following example "/robots.txt" file specifies that no robots should visit any URL starting with "/cyberworld/map/" or "/tmp/":