From: Jan "Yenya" Kasprzak Date: Fri, 8 Dec 2023 08:07:36 +0000 (+0100) Subject: Input downloader: use spew() instead of spurt() X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=dcb860dd4089c635c9d7414a631ba183d80e013b;p=aoc.git Input downloader: use spew() instead of spurt() --- diff --git a/get b/get index 13a39df..0ed2728 100755 --- a/get +++ b/get @@ -46,7 +46,7 @@ if ($sleep) { say "Downloading $url to $dest"; my $data = Y::AoC::UA::request($url, { body => 1 }); -Mojo::File->new($dest)->spurt($data); +Mojo::File->new($dest)->spew($data); say grey('=================================================='); print $data; say grey('=================================================='); @@ -59,5 +59,5 @@ $dest = $task.'test.txt'; my $tst = Y::AoC::UA::request($url, { cache_to => "task-$year-$day.html" }) ->find('main > article > pre > code')->first->all_text; -Mojo::File->new($dest)->spurt($tst); +Mojo::File->new($dest)->spew($tst); say "\n", grey("also downloaded $dest"), "\n"; diff --git a/lib/Y/AoC/UA.pm b/lib/Y/AoC/UA.pm index 7258324..966878a 100644 --- a/lib/Y/AoC/UA.pm +++ b/lib/Y/AoC/UA.pm @@ -5,7 +5,7 @@ use v5.36; use Mojo::Base -signatures; use Mojo::UserAgent; use Mojo::DOM; -use Y::AoC qw(white); +use Y::AoC qw(white red); our $user_agent = 'kas@yenya.net https://www.fi.muni.cz/~kas/git/aoc.git'; our $cache_dir = '/home/kas/aoc/cache'; @@ -55,7 +55,7 @@ sub request($url, $args) { } if ($cache) { - $cache->spurt($res->body); + $cache->spew($res->body); # say "Stored response to $cachefile"; } return $args->{body} ? $res->body : $res->dom;