Robert Barta > WWW-Agent > WWW::Agent

Download:
WWW-Agent-0.03.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.03   Source  

NAME ^

WWW::Agent - Abstract web browser

SYNOPSIS ^

   use WWW::Agent
   use WWW::Agent::Plugins::Focus;
   ...
   $agent = new WWW::Agent (plugins => [
                                        new WWW::Agent::Plugins::Focus,
                                        ...
                                        ]);
   $agent->run;

DESCRIPTION ^

The web agent is a minimalistic web browser, in that the only thing it supports is to request an object. For this purpose, it maintains a concept of tabs, similar to those found in most modern web browsers. A request will be done in the context of a particular tab. As a consequence, the agents can handle multiple requests, also concurrently. This is achieved by using POE underneath.

As the agent is otherwise dumb, it is up to plugins to do something useful. The range of possible features which plugins can add is considerable: Plugins can take care off testing websites for correct behaviour, scraping web sites and lauching external function, spidering sites to analyze pages or link structures, etc.

Plugin Events

See WWW::Agent::Plugins.

INTERFACE ^

Constructor

The constructor expects a hash with the following key/value pairs:

name (string):

This is currently ignored.

plugins (list reference, optional):

Any number of plugins can be loaded into an agent. Each plugin must be an object (instantiated from the appropriate class).

The sequence of plugins in the list is significant as two or more plugins might register for one and the same event. The execution of the individual handler is organized according to the list.

ua (LWP::UserAgent object, optional):

This object will be used to launch requests. Obviously any subclass can be used, say, for providing special headers or one providing additional caching.

If no LWP::UserAgent object is passed in, the a generic one will be used.

Methods

run (no parameters)

This method makes the agent run and do whatever it is told to do. If you have not posted any requests to cycle_start before that, then the agent will immediately terminate.

Consequently it is either your responsibility to task the agent with requests, or the responsibility of specific plugins to do that. One other option is to set up another POE session which posts events to the agent (it's POE name is agent, btw).

Example:

   my $a = new WWW::Agent (....);
   use POE;
   POE::Kernel->post ('agent', 'cycle_start', 'new_tab', 'http://www.example.org/');
   $a->run;  # fetch it and ... that's it

SEE ALSO ^

WWW::Agent::Plugins, LWP::UserAgent, POE

AUTHOR ^

Robert Barta, <rho@bigpond.net.au>

COPYRIGHT AND LICENSE ^

Copyright (C) 2005 by Robert Barta

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.4 or, at your option, any later version of Perl 5 you may have available.

syntax highlighting: