home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 May / Chip_2000-05_cd1.bin / zkuste / Perl / ActivePerl-5.6.0.613.msi / 䆊䌷䈹䈙䏵-䞅䞆䞀㡆䞃䄦䠥 / _1fc36d985e4dc7fa27c3feadd8f3350f < prev    next >
Text File  |  2000-03-23  |  6KB  |  163 lines

  1.  
  2. <HTML>
  3. <HEAD>
  4. <TITLE>WWW::RobotsRules - Parse robots.txt files</TITLE>
  5. <LINK REL="stylesheet" HREF="../../../Active.css" TYPE="text/css">
  6. <LINK REV="made" HREF="mailto:">
  7. </HEAD>
  8.  
  9. <BODY>
  10. <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
  11. <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
  12. <STRONG><P CLASS=block> WWW::RobotsRules - Parse robots.txt files</P></STRONG>
  13. </TD></TR>
  14. </TABLE>
  15.  
  16. <A NAME="__index__"></A>
  17. <!-- INDEX BEGIN -->
  18.  
  19. <UL>
  20.  
  21.     <LI><A HREF="#name">NAME</A></LI><LI><A HREF="#supportedplatforms">SUPPORTED PLATFORMS</A></LI>
  22.  
  23.     <LI><A HREF="#synopsis">SYNOPSIS</A></LI>
  24.     <LI><A HREF="#description">DESCRIPTION</A></LI>
  25.     <LI><A HREF="#robots.txt">ROBOTS.TXT</A></LI>
  26.     <LI><A HREF="#robots.txt examples">ROBOTS.TXT EXAMPLES</A></LI>
  27.     <LI><A HREF="#see also">SEE ALSO</A></LI>
  28. </UL>
  29. <!-- INDEX END -->
  30.  
  31. <HR>
  32. <P>
  33. <H1><A NAME="name">NAME</A></H1>
  34. <P>WWW::RobotsRules - Parse robots.txt files</P>
  35. <P>
  36. <HR>
  37. <H1><A NAME="supportedplatforms">SUPPORTED PLATFORMS</A></H1>
  38. <UL>
  39. <LI>Linux</LI>
  40. <LI>Solaris</LI>
  41. <LI>Windows</LI>
  42. </UL>
  43. <HR>
  44. <H1><A NAME="synopsis">SYNOPSIS</A></H1>
  45. <PRE>
  46.  require WWW::RobotRules;
  47.  my $robotsrules = new WWW::RobotRules 'MOMspider/1.0';</PRE>
  48. <PRE>
  49.  use LWP::Simple qw(get);</PRE>
  50. <PRE>
  51.  $url = "<A HREF="http://some.place/robots.txt"">http://some.place/robots.txt"</A>;;
  52.  my $robots_txt = get $url;
  53.  $robotsrules->parse($url, $robots_txt);</PRE>
  54. <PRE>
  55.  $url = "<A HREF="http://some.other.place/robots.txt"">http://some.other.place/robots.txt"</A>;;
  56.  my $robots_txt = get $url;
  57.  $robotsrules->parse($url, $robots_txt);</PRE>
  58. <PRE>
  59.  # Now we are able to check if a URL is valid for those servers that
  60.  # we have obtained and parsed "robots.txt" files for.
  61.  if($robotsrules->allowed($url)) {
  62.      $c = get $url;
  63.      ...
  64.  }</PRE>
  65. <P>
  66. <HR>
  67. <H1><A NAME="description">DESCRIPTION</A></H1>
  68. <P>This module parses a <EM>/robots.txt</EM> file as specified in
  69. ``A Standard for Robot Exclusion'', described in
  70. <http://info.webcrawler.com/mak/projects/robots/norobots.html>
  71. Webmasters can use the <EM>/robots.txt</EM> file to disallow conforming
  72. robots access to parts of their web site.</P>
  73. <P>The parsed file is kept in the WWW::RobotRules object, and this object
  74. provides methods to check if access to a given URL is prohibited.  The
  75. same WWW::RobotRules object can parse multiple <EM>/robots.txt</EM> files.</P>
  76. <P>The following methods are provided:</P>
  77. <DL>
  78. <DT><STRONG><A NAME="item_new">$rules = WWW::RobotRules-><CODE>new($robot_name)</CODE></A></STRONG><BR>
  79. <DD>
  80. This is the constructor for WWW::RobotRules objects.  The first 
  81. argument given to <A HREF="#item_new"><CODE>new()</CODE></A> is the name of the robot.
  82. <P></P>
  83. <DT><STRONG><A NAME="item_parse">$rules->parse($url, $content, $fresh_until)</A></STRONG><BR>
  84. <DD>
  85. The <A HREF="#item_parse"><CODE>parse()</CODE></A> method takes as arguments the URL that was used to
  86. retrieve the <EM>/robots.txt</EM> file, and the contents of the file.
  87. <P></P>
  88. <DT><STRONG><A NAME="item_allowed">$rules-><CODE>allowed($url)</CODE></A></STRONG><BR>
  89. <DD>
  90. Returns TRUE if this robot is allowed to retrieve this URL.
  91. <P></P>
  92. <DT><STRONG><A NAME="item_agent">$rules-><CODE>agent([$name])</CODE></A></STRONG><BR>
  93. <DD>
  94. Get/set the agent name. NOTE: Changing the agent name will clear the robots.txt
  95. rules and expire times out of the cache.
  96. <P></P></DL>
  97. <P>
  98. <HR>
  99. <H1><A NAME="robots.txt">ROBOTS.TXT</A></H1>
  100. <P>The format and semantics of the ``/robots.txt'' file are as follows
  101. (this is an edited abstract of
  102. <http://info.webcrawler.com/mak/projects/robots/norobots.html>):</P>
  103. <P>The file consists of one or more records separated by one or more
  104. blank lines. Each record contains lines of the form</P>
  105. <PRE>
  106.   <field-name>: <value></PRE>
  107. <P>The field name is case insensitive.  Text after the '#' character on a
  108. line is ignored during parsing.  This is used for comments.  The
  109. following <field-names> can be used:</P>
  110. <DL>
  111. <DT><STRONG><A NAME="item_User%2DAgent">User-Agent</A></STRONG><BR>
  112. <DD>
  113. The value of this field is the name of the robot the record is
  114. describing access policy for.  If more than one <EM>User-Agent</EM> field is
  115. present the record describes an identical access policy for more than
  116. one robot. At least one field needs to be present per record.  If the
  117. value is '*', the record describes the default access policy for any
  118. robot that has not not matched any of the other records.
  119. <P></P>
  120. <DT><STRONG><A NAME="item_Disallow">Disallow</A></STRONG><BR>
  121. <DD>
  122. The value of this field specifies a partial URL that is not to be
  123. visited. This can be a full path, or a partial path; any URL that
  124. starts with this value will not be retrieved
  125. <P></P></DL>
  126. <P>
  127. <HR>
  128. <H1><A NAME="robots.txt examples">ROBOTS.TXT EXAMPLES</A></H1>
  129. <P>The following example ``/robots.txt'' file specifies that no robots
  130. should visit any URL starting with ``/cyberworld/map/'' or ``/tmp/'':</P>
  131. <PRE>
  132.   User-agent: *
  133.   Disallow: /cyberworld/map/ # This is an infinite virtual URL space
  134.   Disallow: /tmp/ # these will soon disappear</PRE>
  135. <P>This example ``/robots.txt'' file specifies that no robots should visit
  136. any URL starting with ``/cyberworld/map/'', except the robot called
  137. ``cybermapper'':</P>
  138. <PRE>
  139.   User-agent: *
  140.   Disallow: /cyberworld/map/ # This is an infinite virtual URL space</PRE>
  141. <PRE>
  142.   # Cybermapper knows where to go.
  143.   User-agent: cybermapper
  144.   Disallow:</PRE>
  145. <P>This example indicates that no robots should visit this site further:</P>
  146. <PRE>
  147.   # go away
  148.   User-agent: *
  149.   Disallow: /</PRE>
  150. <P>
  151. <HR>
  152. <H1><A NAME="see also">SEE ALSO</A></H1>
  153. <P><A HREF="../../../site/lib/LWP/RobotUA.html">the LWP::RobotUA manpage</A>, <A HREF="../../../site/lib/WWW/RobotRules/AnyDBM_File.html">the WWW::RobotRules::AnyDBM_File manpage</A></P>
  154. <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
  155. <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
  156. <STRONG><P CLASS=block> WWW::RobotsRules - Parse robots.txt files</P></STRONG>
  157. </TD></TR>
  158. </TABLE>
  159.  
  160. </BODY>
  161.  
  162. </HTML>
  163.