App::Wubot::Util::WebFetcher - fetch content from the web
version 0.3.5
use App::Wubot::Util::WebFetcher; has 'fetcher' => ( is => 'ro', isa => 'App::Wubot::Util::WebFetcher', lazy => 1, default => sub { return App::Wubot::Util::WebFetcher->new(); }, ); my $content; eval { # try $content = $self->fetcher->fetch( $config->{url}, $config ); 1; } or do { # catch my $error = $@; my $subject = "Request failure: $error"; $self->logger->error( $self->key . ": $subject" ); return { cache => $cache, react => { subject => $subject } }; };
Fetch data from a URL using LWP::UserAgent.
This utility class is designed to be used by wubot plugins in the classes App::Wubot::Plugin and App::Wubot::Reactor.
Fetches content from the specified URL.
If the fetch attempt fails, then this method will die with the error message. Plugins that wish to use this library should wrap the fetch() method in an eval block (see the example above).
The data fetched will be passed to utf8::encode().
The 'config' may contain the following settings:
Number of seconds before the fetch times out. Defaults to 20 seconds.
The user agent string. Defaults to 'Mozilla/6.0'.
User id for basic auth. See also 'pass'
Password for basic auth. See also 'user'.
The proxy URL.
If true, sets the Accept-Encoding using HTTP::message::decodable.
To install App::Wubot, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::Wubot
CPAN shell
perl -MCPAN -e shell install App::Wubot
For more information on module installation, please visit the detailed CPAN module installation guide.