From: Marius Gavrilescu Date: Sun, 12 Jul 2015 10:30:24 +0000 (+0300) Subject: Replace LWP with HTTP::Tiny X-Git-Tag: 1.000~5 X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=e90bc6161036203425f93442bcc23dc2a3c86e34;p=www-offliberty.git Replace LWP with HTTP::Tiny --- diff --git a/Makefile.PL b/Makefile.PL index a123b40..191da8e 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -16,7 +16,7 @@ WriteMakefile( PREREQ_PM => { qw/Getopt::Long 0 HTML::TreeBuilder 0 - LWP::UserAgent 0/ + HTTP::Tiny 0/ }, META_ADD => { dynamic_config => 0, diff --git a/lib/WWW/Offliberty.pm b/lib/WWW/Offliberty.pm index 3f9a152..a8ca576 100644 --- a/lib/WWW/Offliberty.pm +++ b/lib/WWW/Offliberty.pm @@ -7,15 +7,18 @@ use parent qw/Exporter/; our $VERSION = '0.002'; our @EXPORT_OK = qw/off/; +use constant OFF_URL => 'http://offliberty.com/off54.php'; + use HTML::TreeBuilder; -use LWP::UserAgent; +use HTTP::Tiny; -my $ua = LWP::UserAgent->new; +my $http = HTTP::Tiny->new(agent => "WWW-Offliberty/$VERSION "); sub off{ my ($url, @params) = @_; - my $content = $ua->post("http://offliberty.com/off54.php", {track => $url, @params})->decoded_content; - my $root = HTML::TreeBuilder->new_from_content($content); + my $ret = $http->post_form(OFF_URL, {track => $url, @params}); + die $ret->{reason} unless $ret->{success}; + my $root = HTML::TreeBuilder->new_from_content($ret->{content}); map { $_->attr('href') } $root->look_down(qw/_tag a class download/); }