Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: Perl/Tk --- Weather Map Grabber

by teabag (Pilgrim)
on Jul 25, 2003 at 10:19 UTC ( #277836=note: print w/replies, xml ) Need Help??

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 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 => "$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 ;)

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

Replies are listed 'Best First'.
Re: Re: Perl/Tk --- Weather Map Grabber
by PERLscienceman (Curate) on Jul 25, 2003 at 22:12 UTC
    Greetings! Thank you for your reply and feedback. Have you seen this particular module: Geo::WeatherNWS ? I have been developing some code to work with it (not quite ready to post yet). In a nutshell, you input the the station ID code, it goes to a National Weather Service Database, gets the current conditions report, parses it, and outputs values such as temperature, relative humidity, windspeed+direction, etc..... I believe it is well worth your time to take a look at!

    Anyway that is my 2 cents worth! Thanks again for your input.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://277836]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2020-11-27 11:06 GMT
Find Nodes?
    Voting Booth?

    No recent polls found