http://qs321.pair.com?node_id=277836


in reply to Perl/Tk --- Weather Map Grabber

Excellent work,

But maybe you can add some weather textinfo though. If you decide to do so, you can use the code below to get the ICAO info from an airport close to your house.

I fetched this info with Net::FTP, (which is a little bit faster I believe?) but LWP::Simple works just as good.

#!/usr/bin/perl -w use strict; use LWP::Simple; use HTTP::Request; #Name your city, village, carton box my $city = "My City"; #Text to appear in above weatherreport my $wthrtext = "Current Weather in $city:"; # Your very own ICAO location. See http://weather.noaa.gov for more i +nfo... my $weathericao = "EHAM.TXT"; # Create yer user agent object use LWP::UserAgent; my $ua = new LWP::UserAgent; $ua->agent( "WeatherBot " . $ua->agent ); # Add your request ;) my $req = HTTP::Request->new( GET => "ftp://weather.noaa.gov/data/observations/metar/decoded/$weather +icao" ); $req->header( Accept => "text/html, */*;q=0.1" ); # Now pass that request to the user agent and get a response back my $res = $ua->request($req); # Check the outcome of the response if ( $res->is_success ) { print "Fetched weather...\n\n"; } else { print "Nope, couldn't fetch weather...\n"; exit; } my $weather = $res->content; #Bring on the sunshine! print "$wthrtext\n\n$weather";

Aaaah, Sunshine ;)

Teabag
Sure there's more than one way, but one just needs one anyway - Teabag