Replace HTTP::Tiny with Mojo::UserAgent and Mojo::UserAgent::Cached

This commit is contained in:
eleksir
2021-04-05 00:56:27 +03:00
parent b8fb89358e
commit 57dee8b168
9 changed files with 205 additions and 199 deletions

View File

@@ -7,9 +7,9 @@ use utf8;
use open qw (:std :utf8);
use English qw ( -no_match_vars );
use Carp qw (cluck);
use HTTP::Tiny;
use HTML::TokeParser;
use Math::Random::Secure qw (irand);
use Mojo::UserAgent;
use version; our $VERSION = qw (1.0);
use Exporter qw (import);
@@ -21,18 +21,18 @@ sub monkeyuser {
my @link;
for (1..3) {
my $http = HTTP::Tiny->new (timeout => 3);
$r = $http->get ('https://www.monkeyuser.com/toc/');
my $ua = Mojo::UserAgent->new->connect_timeout (3);
$r = $ua->get ('https://www.monkeyuser.com/toc/')->result;
if ($r->{success}) {
if ($r->is_success) {
last;
}
sleep 2;
}
if ($r->{success}) {
my $p = HTML::TokeParser->new(\$r->{content});
if ($r->is_success) {
my $p = HTML::TokeParser->new(\$r->body);
my @a;
do {