Published in: Perl
Expects a newline-delimited list of RSS feed urls. Prints an HTML 4 page containing a grid of modules. The modules contain hyperlinked feed headlines.
Very fragile, any invalid feed will break the whole aggregator.
#! /usr/bin/perl -w BEGIN { # Add the directory where this file is to the beginning of @INC } use strict; use RSS2html; use NoFace; #old script to scrape weather.com. broken. #yubaba.pl is the RSS feed script it should be run by a cron job every half-hour or so. #sussman may 03 #**************************************************************** # REMEMBER TO REMOVE SLASHDOT FROM rssList.txt BEFORE TESTING! * #**************************************************************** #MAIN my $rss_feeds = "/home/suburban/public_html/yubaba/rssList.txt"; #List of RSS uris, one per line my $non_rss = "/home/suburban/public_html/yubaba/nonRss.txt"; my $parser = new rss2html; my $grab = new NoFace; my $display = new CGI; #my %syndicate = $grab -> get_facts ($non_rss); #wtr_high, wtr_low, wtr_cloud_condition, wtr_tomorrow_temp, wtr_tomorrow_cloud #print $display->header; #print start_html(-title=>'suburbanangst.com: news', # -head=>Link({-rel=>"stylesheet", # -href=>"http://suburbanangst.com/style.css"}) # ); -head=> Link( { -rel=>"stylesheet", -href=>"http://suburbanangst.com/style.css" } ), -script=> { type=>"text/javascript", code=>'setTimeout("window.location.reload(true)", 900*1000); // refresh time in ms' } ); print <<HTML; <table width="100%"> <tr> <td style="text-align: center;"><a href="bookmarks.html">Bookmarks</a> || <a href="http://onemorebug.com">OneMoreBug.com</a> || <a href="http://tommyz.net">TommyZ.net</a> || <a href="http://OneMoreBug.com/">Web Design Seminar</a> || <a href="/PL/">Perl Scripts</a> </td> </tr> <tr> <td style="text-align: center;"><a href="help/">Resources</a> || <a href="game/">GURPS Teleria</a> </td> </tr> <tr> <td style="text-align: center;"> <h3>Welcome to Suburban Angst!</h3> </td> </tr> HTML print "<tr><td style=\"text-align: center;\">"; print "</td></tr><tr><td style=\"text-align: center;\"><a href=\"http://www.srh.noaa.gov/data/forecasts/NYZ072.php?warncounty=NYC061&city=New+York\">Weather</a> || <a href=\"http://nyt.com\">New York Times</a> || <a href=\"http://google.com\">Google</a> || <a href=\"http://h2odev.law.harvard.edu/ezuckerman/\">Google Map</a>"; print "<p></p><!-- <p style=\"text-align: center;\">Last updated "; print " PST<p/> gotta fix this! -->"; #THE KKK TOOK MY WEATHER CHANNEL AWAY #print "<p>$syndicate{'wtr_cloud_condition'}, <b>$syndicate{'wtr_high'}</b>, High/Low: <b>$syndicate{'wtr_low'}.</b> Precip: <b>$syndicate{'wtr_precip'}.</b> <i>Tomorrow:</i> $syndicate{'wtr_tomorrow_cloud'}, $syndicate{'wtr_tomorrow_temp'}, precip: $syndicate{'wtr_tomorrow_precip'}.</p>"; print "<a href=\"http://dailyrotten.com\">Daily Rotten</a> || <a href=\"http://consumptionjunction.com/content/browse.asp?type=8\">Consumption Junction Daily</a> || <a href=\"http://freshnews.org\">FreshNews</a></p>"; print "</td></tr></table>\n"; print <<HTML; <table cellspacing="10" width="60%%" align="center"> HTML render($rss_feeds); print <<HTML; </table> HTML #**************************************************************** # SUBROUTINES * #**************************************************************** sub render { my $counter = 0; #counts the number of boxes my $other_counter = 0; #counts the number of boxes in a column my $number_of_entries = 0; #must be an even number. half the entries go in one column, half in the other. overflow entries span the whole screen. #**************** #Assumes we are reading a file with one URL on each line #**************** while (<>) { if ($url ne "") { } if ($other_counter == 0) { print '<td class="blogborder"><!--2a-->'; } $parser -> rss_get ($url); if ($other_counter >= ($number_of_entries / 2) -1) { print "<!--2b--></td>"; $other_counter = 0; } else { ++$other_counter; } if ($counter >= ($number_of_entries) -1 ) { print "</tr><!--1b-->"; $counter = 0; } else { ++$counter; } } } }
You need to login to post a comment.
