http://www.perlmonks.org?node_id=618173


in reply to Automated extraction of NOAA weather satellite images

As it happens, I wrote a very similar script a couple of weeks ago. Rather than using the current time though, mine builds a timestamp from the Last-Modified header of the response, so the timestamp is the last time the image was updated, and you can run it as often as you want without downloading duplicate images.

#!/usr/local/bin/perl -w ################## # Copyright 2007 Jason Kohles (JSK), <email@jasonkohles.com> ################## use strict; use warnings; use LWP::Simple qw( getstore head ); use POSIX 'strftime'; #chdir( "/home/weather/noaa-goes-images" ) or die "Cannot chdir: $!"; for my $loc ( qw( EC WC ) ) { for my $type ( qw( VS IR WV ) ) { my $url = "http://www.goes.noaa.gov/GIFS/".$loc.$type.".JPG"; my $epoch = ( head( $url ) )[ 2 ] || next; my $time = strftime( '%F-%T', gmtime( $epoch ) ); my $file = lc( join( '-', $loc, $type, $time ).'.jpg' ); next if -f $file; print "Retrieving $url to $file\n"; getstore( $url, $file ); } }

We're not surrounded, we're in a target-rich environment!