Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

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 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


Comment on Re: Perl/Tk --- Weather Map Grabber
Select or Download Code
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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (10)
As of 2014-09-17 17:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (92 votes), past polls