Replace LWP with HTTP::Tiny
[www-offliberty.git] / lib / WWW / Offliberty.pm
index 3f9a152b8e8d7a305cb0283ad5a6617b27d4e5e5..a8ca5769313c192d729bfa7400d59dd89d7146eb 100644 (file)
@@ -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/);
 }
 
This page took 0.009426 seconds and 4 git commands to generate.