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 HTML::TableExtract.
#!/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.


In reply to Re: Weather goest thou, spider? by Aristotle
in thread Weather goest thou, spider? by jens

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.