Perl Diver 2.31
Main Environment Variables Perl Default Values Perl Config - Summary Perl Config - Full Installed Modules List Directory uptime Docs

Module Documentation
Details and documentation about a specific module, including version and documentation (if available). Note that while links to perldoc.com and search.cpan.org are provided, the module may be part of a larger distribution. If you reach a File Not Found page on either site, please try the parent module.

LWP::Parallel::RobotUA

Name LWP::Parallel::RobotUA
Version 1.12
Located at /usr/local/share/perl5
File /usr/local/share/perl5/LWP/Parallel/RobotUA.pm
Is Core No
Search CPAN for this module LWP::Parallel::RobotUA
Documentation LWP::Parallel::RobotUA
Module Details LWP::Parallel::RobotUA

NAME

LWP::Parallel::RobotUA - A class for Parallel Web Robots


SYNOPSIS

  require LWP::Parallel::RobotUA;
  $ua = new LWP::Parallel::RobotUA 'my-robot/0.1', 'me@foo.com';
  $ua->delay(0.5);  # in minutes!
  ...
  # just use it just like a normal LWP::Parallel::UserAgent
  $ua->register ($request, \&callback, 4096); # or
  $ua->wait ( $timeout );


DESCRIPTION

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.


METHODS

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::Parallel::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 the WWW::RobotRules::AnyDBM_File manpage for persistent caching of robot rules in a local file)

$ua->delay([$minutes])

Set/Get the minimum delay between requests to the same server. The default is 1 minute.

Note: Previous versions of LWP Parallel-Robot used Seconds instead of Minutes! This is now compatible with LWP Robot.

$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.


SEE ALSO

the LWP::Parallel::UserAgent manpage, the LWP::RobotUA manpage, the WWW::RobotRules manpage


COPYRIGHT

Copyright 1997-2004 Marc Langheinrich <marclang@cpan.org>

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Perl Diver brought to you by ScriptSolutions.com © 1997- 2024