LWP::Parallel::RobotUA - A class for Parallel Web Robots require LWP::Parallel::RobotUA; $ua = new LWP::Parallel::RobotUA 'my-robot/0.1', 'me@foo.com'; $ua->delay(20); # in seconds! ... # just use it just like a normal LWP::Parallel::UserAgent $ua->register ($request, \&callback, 4096); # or $ua->wait ( $timeout ); This class implements a user agent that is suitable for robot applications. Robots should be nice to the servers they visit. They should consult the /robots.txt file to ensure that they are welcomed and they should not make requests too frequently. But, before you consider writing a robot take a look at <URL:http://info.webcrawler.com/mak/projects/robots/robots.html>. When you use a LWP::Parallel::RobotUA as your user agent, then you do not really have to think about these things yourself. Just send requests as you do when you are using a normal LWP::Parallel::UserAgent and this special agent will make sure you are nice. The LWP::Parallel::RobotUA is a sub-class of LWP::Parallel::UserAgent and LWP::RobotUA and implements a mix of their methods. In addition to LWP::Parallel::UserAgent, these methods are provided:

$ua = LWP::RobotUA->new($agent_name, $from, [$rules])
Your robot's name and the mail address of the human responsible for the robot (i.e. you) are required by the constructor. Optionally it allows you to specify the WWW::RobotRules object to use. (See WWW::RobotRules::AnyDBM_File for persistent caching of robot rules in a local file)

$ua->delay([$seconds])
Set/Get the minimum delay between requests to the same server. The default is 60 seconds. Note: The original LWP Robot uses Minutes instead of Seconds here!

$ua->host_wait($netloc)
Returns the number of seconds you must wait before you can make a new request to this server. This method keeps track of all of the robots connection, and enforces the delay constraint specified via the delay method above for each server individually. Note: Although it says 'host', it really means 'netloc/server', i.e. it differentiates between individual servers running on different ports, even though they might be on the same machine ('host'). This function is mostly used internally, where RobotUA calls it to find out when to send the next request to a certain server.

$ua->as_string
Returns a string that describes the state of the UA. Mainly useful for debugging. LWP::Parallel::UserAgent, LWP::RobotUA, WWW::RobotRules Copyright 1997-2001 Marc Langheinrich <marclang@cs.washington.edu> This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.