#!/usr/bin/perl
use strict;
use LWP::Simple;
use CGI;
#use Text::Autoformat;
#use Time::Local;
my $sfo_url = "http://www.wrh.noaa.gov/total_forecast/getprod.php?sid=MTR&pil=AFD&version=0";
my $sfo_pf_url = "http://www.wrh.noaa.gov/total_forecast/getprod.php?wfo=mtr&pil=AFD&sid=MTR&version=0&banner=off";
my $w = new CGI;
print $w->header;
print $w->title('Bay Area NOAA Forecast Discussion');
print $w->start_html;
print $w->h2('SF Bay Area NOAA Forecast Discussion');
print "\n";
get_forecast_discussion ($sfo_pf_url);
print "\n";
print $w->end_html;
exit(0);
#######################
sub get_forecast_discussion
{
my $url = shift;
my ($forecast);
my $page = get ($url);
# $page =~ m/DELTA-
(\d{3,4} [A-Z]2 [A-Z]{3,4} [A-Z]3 [A-Z]3 \d{1,2} \d4)
(.*)
<\/pre>/s;
$page =~ m/NATIONAL WEATHER SERVICE SAN FRANCISCO CA
(.*?)
<\/pre>/;
# $time = $1;
$forecast = $1;
$forecast =~ s/
/
\n/g;
$forecast =~ s/
/\n/g;
print "\nThe National Weather Service San Francisco Forecast Discussion:
\n "; print $forecast; # print autoformat { case=>'sentence ' }, $forecast; print "
\n";
}
sub grab_wind_img
{my $url = shift;
my $img_tag;
my $page;
$page = get($url);
$page =~ m/\s\n.*src="(.*)"\swidth/s;
#$img_tag = "";
$img_tag = $1;
#print "\****\n$1******\n";
return ($img_tag);
}
sub grab_tide_img
{ my $url = shift;
my ($img_url, $stub, $uri);
my $page;
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday);
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday) = localtime(time);
$year = $year + 1900;
$mon++;
$mon = sprintf ("%02d", $mon);
$mday = sprintf ("%02d", $mday);
#&bdate=20020714&edate=20020715
# ($img_url, $stub) = split(/ /,$url);
$img_url = $url . "&bdate=" . $year . $mon . $mday;
$mday++;
$img_url .= "&edate=" . $year . $mon . $mday;
# $img_url .= $stub;
$page = get ($img_url);
$page =~ m/
$day1
} | |