Initial version.
This commit is contained in:
parent
f6af58961e
commit
d02af73836
12
Makefile.PL
Normal file
12
Makefile.PL
Normal 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
35
bin/bitcoin_monitor.pl
Executable 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/;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user