I wrote two scripts that use German web weather services; both only output to console but they should provide a starting point. One uses regexen to pull out the data (and doesn't work verbatim because their pages seem to frequently move), the other relies on
#!/usr/bin/perl -w
# wetter.pl: gets information from wetter.com
use strict;
use LWP::Simple;
use HTML::Entities;
my $city = shift(@ARGV) || die "usage: ./wetter.pl <location>\n\tlocat
+ion = Ortsname oder PLZ\n";
$_ = get("http://www.wetter.com/home/structure/control.php?Lang=DE&ms=
+1&ss=1&sss=2&search=$city") || die "Dokument konnte nicht uebertragen
+ werden, keine Informationen verfügbar\n\n";
s/^.*<!-- Content Current -->(.*?)<!-- Additional CONTENT -->.*$/$1/si
+ || die "Dokument enthaelt keine Wetterdaten\nWahrscheinlich ist der
+Suchbegriff wetter.com nicht bekannt\n\n";
my @date = /<div class="headlineHell2">(\d\d\.\d\d\.\d\d\d\d)<br>(\d\d
+:\d\d) Uhr Ortszeit<\/div>/si;
my @sky = /<span class="tabHeadline">(.*?)<\/span>/si;
my @wheather = /<span class="tabBody">(.*?)<\/span>/sgi;
decode_entities($_), s/\s+//sg for @date, @sky, @wheather;
print << "EOT";
Messung: @date
Himmel: @sky
Temperatur: @wheather[0,1]
Luftdruck: @wheather[2,3]
Wind: @wheather[5,6,4]
Sicht: @wheather[7,8]
EOT
#!/usr/bin/perl -w
# yahoowetter: parses weather information from the Yahoo! Wetter servi
+ce
use strict;
use LWP::Simple;
use HTML::TableExtract;
print "Yahoo! Wetter - Parserskript 0.1 (Stand 3. Jun 2002)\n";
my $URL;
if(@ARGV) {
$URL = shift @ARGV;
}
else {
open URL, "<", "$ENV{HOME}/.yahoowetter" or die "~/.yahoowetter an
+gelegen oder URL auf der Kommandozeile übergeben\n";
$URL = <URL>;
close URL;
}
sub prettify { s/\s+/ /sg, s/^\s+//, s/:?$// for $_[0]; $_[0] }
(my $extractor = new HTML::TableExtract)->parse(get($URL) or die "Kein
+e Daten geladen (sind wir online?)\n");
my @valuenames = qw(Temperatur Zeitpunkt);
my @weather;
push @weather, (map [ shift(@valuenames), prettify($_->[0]) ], $extrac
+tor->table_state(4,0)->rows());
push @weather, (map [ split(/\W/, prettify($_->[2]), 2) ], $extractor-
+>table_state(3,1)->rows());
push @weather, (map [ map prettify($_), @$_ ], $extractor->table_state
+(3,2)->rows());
@weather[0,1] = @weather[1,0];
$_->[0] =~ s/$/:/ for @weather;
printf "%-20s %s\n", @$_ for @weather;
print "\n";
Makeshifts last the longest.