Weather Forecast
Rick Measham
rickm at isite.net.au
Sun Sep 15 20:50:41 CDT 2002
G'day Jens,
The BOM's page titles are static despite the look of the URL. The
precis forecast will always be at
http://www.bom.gov.au/cgi-bin/wrap_fwo.pl?IDV10420.txt thus you could
get rid of your first call to the index page.
Their perl script merely reads a text file from their file server and
wraps some HTML around it. 'IDV10420.txt' is the file that contains
Melbourne's precis forecast.
Cheers!
Rick Measham
#!/usr/bin/perl
use strict;
use warnings;
use HTML::TokeParser;
use LWP 5.65;
use Mail::Send;
my $destination_webpage =
q|http://www.bom.gov.au/cgi-bin/wrap_fwo.pl?IDV10420.txt|;
my $browser = LWP::UserAgent->new;
my $response = $browser->get( $destination_webpage );
die "Can't get $destination_webpage -- ", $response->status_line
unless $response->is_success;
die "Hey, I was expecting HTML, not ", $response->content_type unless
$response->content_type eq 'text/html';
my $webpage_contents = $response->content;
my $weather_report = HTML::TokeParser->new( \$webpage_contents );
if ($weather_report->get_tag( "pre" )) {
my $forecast = $weather_report->get_text;
my $msg = new Mail::Send Subject=>"Today's Forecast",
To=>'YourName at YourAddress.com.au';
my $fh = $msg->open;
print $fh "$forecast";
$fh->close;
}
--
--------------------------------------------------------
iSite Technology Consultants
- Internet and PC Consulting
- Software and Web development
- Database design and administration
--------------------------------------------------------
5 Kay Court
Yallambie 3085
http://www.isite.net.au
(03) 9457 2045
--------------------------------------------------------
There are 10 kinds of people:
those that understand binary, and those that don't.
--------------------------------------------------------
More information about the Melbourne-pm
mailing list