|
PLACES TO GO:
|
|
GETSNOW
#!/usr/bin/perl -w
use strict;
use LWP::Simple;
####################################################################
# GETSNOW - A lookup utility for getting city snow depth reports from
# wunderground.com's listing.
# Copyleft 2005 - Nathan E. Pralle
#
# DESCRIPTION: This utility queries Wunderground.com's snow depth listing
# and parses it to derive whatever state and cities you want
# to see the snow depth for.
#
# SYNTAX: perl getsnow.pl [] ... (multi-word names in quotes)
# IE: perl getsnow Hampton Sheffield "Mason City"
#
# REQUIRED: LWP::Simple module
#
# CONTACT: Questions, comments, etc.
# http://www.nathanpralle.com/contact.html
####################################################################
########################
# CONFIGURATION OPTIONS
my $state="IA"; #2-letter state abbreviation
#######################
my $url="http://www.wunderground.com/StateSnowDepth.asp?state=$state";
my $content=get $url;
die "Couldn't get $url\n" unless defined $content;
my @array=split(/\n/,$content);
my $flag=0;
foreach my $line (@array){
if($line=~/\/){
$flag=1;
next;
}
if($line=~/\<\/pre\>/){
$flag=0;
}
if($flag){
foreach my $option(@ARGV){
if($line=~/$option/){
my @snowarray=split(/\s\s+/,$line);
if(defined $snowarray[5] && defined $snowarray[6]){
print "$snowarray[0] has $snowarray[1] inches, $snowarray[2] inches in 24 hours, ";
print "as of $snowarray[5] $snowarray[6]\n";
}
}
}
}
}
This site and all content (C)2002-2008 Nathan E. Pralle (www.nathanpralle.com).
|