TaskPipe::UserAgentManager - base class for managing requests in TaskPipe
You can use this class with TaskPipe::Task_Scrape by specifying it as the useragent manager to use in your project config. The useragent handler module specified in the ua_handler_module setting in your config should provide the useragent handler TaskPipe::UserAgentManager will use. E.g.:
ua_handler_module
TaskPipe::Task_Scrape::Settings: ua_mgr_module: TaskPipe::UserAgentManager ua_handler_module: TaskPipe::UserAgentManager::UserAgentHandler # ...
If you want to modify the way TaskPipe makes requests you can inherit from TaskPipe::UserAgentManager and create your own UserAgentManager. The format for your custom useragent manager might be as follows:
package TaskPipe::UserAgentManager_MyUAManager; use Moose; sub init{ my ($self) = @_; # do something on initialisation } sub before_request($self,method,@params){ # method = 'get', 'post', ... # params = whatever params were passed when # the request was made (url etc) # # Do something directly before the request happens } sub after_request($self,$resp,$method,@params){ # resp = the HTTP::Response object # # Do something directly after the request happens } __PACKAGE__->meta->make_immutable; 1;
If you are thinking of inheriting from TaskPipe::UserAgentManager, see the modules included in TaskPipe already for exmples of how to do this:
TaskPipe
TaskPipe::UserAgentManager_ProxyNet TaskPipe::UserAgentManager_ProxyNet_TOR TaskPipe::UserAgentManager_ProxyNet_Open
See TaskPipe::UserAgentManager::UserAgentHandler for more information about handlers.
Tom Gracey <tomgracey@gmail.com>
Copyright (c) Tom Gracey 2018
TaskPipe is free software, licensed under
The GNU Public License Version 3
To install TaskPipe, copy and paste the appropriate command in to your terminal.
cpanm
cpanm TaskPipe
CPAN shell
perl -MCPAN -e shell install TaskPipe
For more information on module installation, please visit the detailed CPAN module installation guide.