$ ./1.icons.pl { "\@context" => [], "icons" => { bkn => { description => "Mostly cloudy" }, blizzard => { description => "Blizzard" }, cold => { description => "Cold" }, dust => { description => "Dust" }, few => { description => "A few clouds" }, fog => { description => "Fog/mist" }, fzra => { description => "Freezing rain" }, haze => { description => "Haze" }, hot => { description => "Hot" }, hurricane => { description => "Hurricane conditions" }, ovc => { description => "Overcast" }, rain => { description => "Rain" }, rain_fzra => { description => "Rain/freezing rain" }, rain_showers => { description => "Rain showers (high cloud cover)" }, rain_showers_hi => { description => "Rain showers (low cloud cover)" }, rain_sleet => { description => "Rain/sleet" }, rain_snow => { description => "Rain/snow" }, sct => { description => "Partly cloudy" }, skc => { description => "Fair/clear" }, sleet => { description => "Sleet" }, smoke => { description => "Smoke" }, snow => { description => "Snow" }, snow_fzra => { description => "Freezing rain/snow" }, snow_sleet => { description => "Rain/sleet" }, tornado => { description => "Tornado" }, tropical_storm => { description => "Tropical storm conditions" }, tsra => { description => "Thunderstorm (high cloud cover)" }, tsra_hi => { description => "Thunderstorm (low cloud cover)" }, tsra_sct => { description => "Thunderstorm (medium cloud cover)" }, wind_bkn => { description => "Mostly cloudy and windy" }, wind_few => { description => "A few clouds and windy" }, wind_ovc => { description => "Overcast and windy" }, wind_sct => { description => "Partly cloudy and windy" }, wind_skc => { description => "Fair/clear and windy" }, }, } URL = https://api.weather.gov/icons/land/day/tsra_sct,20/tsra_sct,40?size=medium tsra_sct => 'Thunderstorm (medium cloud cover)' URL = https://api.weather.gov/icons/land/day/rain_showers,30/tsra_hi,30?size=medium tsra_hi => 'Thunderstorm (low cloud cover)' URL = https://api.weather.gov/icons/land/night/rain_showers,30/rain_showers?size=medium rain_showers => 'Rain showers (high cloud cover)' URL = https://api.weather.gov/icons/land/day/bkn?size=medium bkn => 'Mostly cloudy' $ #### #!/usr/bin/perl -w use strict; use LWP::UserAgent; use Data::Dump; use JSON::Parse 'parse_json'; my $ua = LWP::UserAgent->new( 'send_te' => '0' ); my $r = HTTP::Request->new( 'GET' => 'https://api.weather.gov/icons', [ 'Cache-Control' => 'max-age=0', 'Connection' => 'keep-alive', 'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'Accept-Encoding' => 'gzip, x-gzip, deflate, x-bzip2, bzip2', 'Accept-Language' => 'en-US,en;q=0.5', 'Host' => 'api.weather.gov:443', 'User-Agent' => 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0', 'Upgrade-Insecure-Requests' => '1', ], ); my $out; my $res = $ua->request( $r, ); if ( $res->is_success ) { my $json = $res->decoded_content; $out = parse_json $json; } else { print "Error: " . $res->status_line . "\n"; } dd $out; my %xlated_abbrev; #simple abbreviation table => description foreach my $key ( keys %{ $out->{icons} } ) #gen simple xlate table { $xlated_abbrev{$key} = $out->{icons}{$key}{description}; } 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) { my $last_path = ( split( '/', $url ) )[-1]; my ($abbrev_to_xlate) = $last_path =~ /^(\w+)/; print "URL = $url\n"; print " $abbrev_to_xlate => \'$xlated_abbrev{$abbrev_to_xlate}\'\n\n"; } __END__ Created from curl command line curl 'https://api.weather.gov/icons' -H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'Connection: keep-alive' -H 'Upgrade-Insecure-Requests: 1' -H 'Cache-Control: max-age=0' #### #!/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;