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&amp;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>';

Essays

Noun vs Verb

Topology

Evolution of the Weblog APIs

Cohesion

SOAP by Example

A Gentle Introduction to Namespaces

Really Simple Syndication

Expect More

REST + SOAP

Beyond Backlinks

Google's Genius

Neuro Transmitters

Headers and Hrefs

A Gentle Introduction to SOAP

Coping with Change

Manufactured Serendipity

Dealing with Diversity

A Busy Developers Guide to WSDL 1.1

Axis/Radio Interop, Actual and Potential

To Infinity and Beyond: the Quest for SOAP Interoperability

What Object Does SOAP Access?

Favorites

In Praise of Evolvable Systems

Metacrap

The Law of Leaky Abstractions

The Eight Fallacies of Distributed Computing

Permanet, Nearlynet, and Wireless Data

Warnock's Dilemma

Sunir's corollaries

Search

Valid XHTML 1.0!