Initial version.

This commit is contained in:
sergiotarxz 2022-01-22 00:39:17 +01:00
parent f6af58961e
commit d02af73836
2 changed files with 47 additions and 0 deletions

12
Makefile.PL Normal file
View File

@ -0,0 +1,12 @@
use ExtUtils::MakeMaker;
WriteMakefile(
NAME => 'Bitcoin::Monitor',
VERSION => '0.1',
INST_SCRIPT => './bin',
INST_BIN => './bin',
PREREQ_PM => {
'Mojolicious' => 0,
'Const::Fast' => 0,
}
);

35
bin/bitcoin_monitor.pl Executable file
View File

@ -0,0 +1,35 @@
#!/usr/bin/env perl
use v5.30.0;
use strict;
use warnings;
use Mojo::UserAgent;
use Mojo::DOM;
use Const::Fast;
const my $ALARM_NO_ERROR => q(Alarm defunction.);
my $ua = Mojo::UserAgent->new;
while (1) {
say "Searching data";
eval {
my $result = $ua->get(q(https://www.coingecko.com/en))->result->body;
my $dom = Mojo::DOM->new($result);
my $bitcoin = $dom->at(q(.coin-table))->find(q(tr))->[1];
say $bitcoin->all_text =~ s/(?:\s|\r|\n)+/ /gr;
local $SIG{ALRM} = sub {
die $ALARM_NO_ERROR;
};
alarm 60;
my $line = <STDIN>;
alarm 0;
};
if ($@) {
STDERR->say(qq($@)) unless $@ =~ /$ALARM_NO_ERROR/;
}
}