diff options
-rwxr-xr-x | ara.pl | 15 | ||||
-rw-r--r-- | cpanfile | 5 |
2 files changed, 14 insertions, 6 deletions
diff --git a/ara.pl b/ara.pl index 963720d..4f5170a 100755 --- a/ara.pl +++ b/ara.pl @@ -76,15 +76,20 @@ if ( -e $file ) { if ( not -e $file or $file_mtime < Time::Moment->now_utc->minus_minutes(8) or $get_latest ) { - require File::Fetch; + require HTTP::Tiny; # Fetch latest data from api. my $url = 'https://api.covid19india.org/data.json'; - my $ff = File::Fetch->new(uri => $url); - # Save the api response under /tmp. - $file = $ff->fetch( to => '/tmp' ) - or die $ff->error; + my $response = HTTP::Tiny + ->new( verify_SSL => 1 ) + ->mirror($url, $file); + + die "Failed to fetch latest data... +Reason: $response->{reason}\n +Content: $response->{content} +Status: $response->{status}\n" + unless $response->{success}; } # Slurp api response to $file_data. diff --git a/cpanfile b/cpanfile index a809e67..b1b21f6 100644 --- a/cpanfile +++ b/cpanfile @@ -1,6 +1,9 @@ requires 'Time::Moment', '0.44'; requires 'Path::Tiny', '0.114'; -requires 'File::Fetch', '0.56'; +requires 'HTTP::Tiny', '0.076'; requires 'JSON::MaybeXS', '1.004002'; requires 'Text::ASCIITable', '0.22'; requires 'Getopt::Long', '2.5'; + +requires 'IO::Socket::SSL', '1.42' + or 'Net::SSLeay', '1.49'; |