news.pl
#!/usr/bin/perl use HTTP::Date; use POSIX "strftime";
print "Content-type: text/html\r\n\r\n";
chdir "/tmp";
# refresh from source if the version on disk is stale my $url = "http://www.google.com/news"; my $file = "newsheadlines.html"; @stat=stat $file; if ((time() - $stat[9]) > 900) { # 15 minute cache unlink $file; system "wget -q -O $file $url"; system "touch $file"; }
# read into memory open FILE, $file; $_ = join "", <FILE>; close FILE; s/n/ /gm; $start=0;
# output html header print "<html><head>\n"; print '<META http-equiv="refresh" content="3600">'; print "<title>Google Headline News</title>\n"; print '<style type="text/css" media="screen">'; print 'a.banner { text-decoration:none; color:#FFFFFF; font-family: futura, helvetica, arial, sans-serif;}'; print 'a { text-decoration:none; color:#0000CC; }'; print 'a:hover { text-decoration:underline; color:#FF0000; }'; print "</style>\n"; print "</head>\n";
# output google search form print "<table>\n"; print "<tr><td colspan=4 align=right>\n"; print '<FORM method=GET action="http://www.google.com/search">'; print '<A HREF="http://www.google.com/">'; print '<IMG SRC="http://www.google.com/logos/Logo_40wht.gif" border="0" '; print 'ALT="Google" align="absmiddle"></A>'; print '<INPUT TYPE=text name=q size=25 maxlength=255 value="">'; print '<INPUT type=submit name=btnG VALUE="Google Search">'; print '</FORM>'; print "</td></tr>\n";
# output personal links print "<tr valign=\"top"><td>n"; print "<br><a href=\"http://www.cnn.com/">cnn</a>n"; print "<br><a href=\"http://www.msnbc.com/">msnbc</a>"; print "<br><a href=\"http://newsobserver.com/">n&o</a>n"; print "<br><a href=\"http://www.nbc17.com/">nbc17</a>"; print "<br><a href=\"http://www.usatoday.com/">usatoday</a>"; print "<br><a href=\"http://www.wral.com/">wral</a>n"; print "<br><a href=\"http://abclocal.go.com/wtvd/">wtvd</a>n"; print "<br><hr>\n"; print "<a href=\"http://movies.triangle.com/Cary-Crossroads.html">movies</a>n"; print "</td><td>\n"; print "<table width=\"100%" cellpadding="2" cellspacing="0">n";
my @sections = split '<font color="#FFFFFF"'; shift @sections; foreach (@sections){
# output section banner if (/^.*?>(.*?)</font>/) { $title=$1; print "</table></td><td><table>" if ($title =~ /Business/);
if ($title =~ /(.* - Updated) (w*) (d*) *(d*):(d*)/) { $year = strftime "%Y", localtime; $time = str2time("$3-$2-$year $4:$5") + 3*60*60; $title = "$1 " . strftime("%b %d %I:%M %p", localtime($time)); $title =~ s/ 0/ /g; }
print "<tr bgcolor=\"#336699"><td>" . "<a class=\"banner" href="$url/$file#$anchor">$title</a>" . "</td></tr>\n" unless ($title =~ /Top Headlines/); $anchor = $1 if /<a name=(w*)>/; }
# output headlines my @links = split '<a class=g'; shift @links; print "<tr><td>\n"; foreach (@links) { if (/^(.*?)</a>/) { print "<li><A $1</A>\n" unless $1 =~/href=#/; } } print "</td></tr>\n"; }
print "</table>\n"; print "</td></tr></table>\n"; print '</html>';
|
|
© Copyright
2002
Sam Ruby
.
Last update:
9/1/2002; 6:53:33 PM
.
This theme is based on the SoundWaves
(blue) Manila theme. |
|