#!/usr/bin/perl use strict; use warnings; use Log::Log4perl qw(:easy); use WWW::Mechanize::Chrome; my $a = 'b'; my @urls = ( 'https://api.weather.gov/icons/land/day/tsra_sct,20/tsra_sct,40?size=medium', 'https://api.weather.gov/icons/land/day/rain_showers,30/tsra_hi,30?size=medium', 'https://api.weather.gov/icons/land/night/rain_showers,30/rain_showers?size=medium', 'https://api.weather.gov/icons/land/day/bkn?size=medium' ); foreach my $url (@urls) { show_screen( $a, $url ); $a++; } sub show_screen() { my ( $letter, $url ) = @_; my $mech = WWW::Mechanize::Chrome->new(); $mech->get($url); my $page_png = $mech->content_as_png(); my $base = '/home/hogan/5.scripts/1.corion./template_stuff/aimages'; my $fn = $base . "/$letter.png"; open my $fh, '>', $fn or die "Couldn't create '$fn': $!"; binmode $fh, ':raw'; print $fh $page_png; close $fh; print "exiting show_screen with letter $letter\n"; } sleep 1;