From e90bc6161036203425f93442bcc23dc2a3c86e34 Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Sun, 12 Jul 2015 13:30:24 +0300 Subject: [PATCH] Replace LWP with HTTP::Tiny --- Makefile.PL | 2 +- lib/WWW/Offliberty.pm | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) 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/); } -- 2.39.2