#!/usr/bin/perl -w # Perl cgi that will get the Atom feed from a site (blogger) # and display the title and links. Suitable for a simple # RSS box on a website. # # Creator: Stephen K. Anthony (http://stephenanthony.ca) # Date: December 19, 2004 # ADDITIONS for new blogger by brian greene (http://www.briangreene.com) # Date: Jan/Feb, 2007 # # Note: Would have used XML::Atom would they have worked with ActivePerl. # This script is a little less useful, and a little more cumbersome as a result. use LWP::Simple; use LWP::UserAgent; use CGI qw(:standard); use CGI::Carp qw(warningsToBrowser fatalsToBrowser); use strict; my($ua) = LWP::UserAgent->new; # Accessing Atom feed my($req) = HTTP::Request->new(GET => 'http://www.YOUR-DOMAIN.ie/atom.xml'); my($res) = $ua->request($req); print header; #print start_html("Blogger Feed"); my $xml = $res->content; my $line=1; =for # use the block for old blogger # by removing the for-cut and comment out new blogger block while( $xml =~ m/"; } if($line gt 0){print "

"; } print ""; print "$3
"; if($line gt 0){print "<\/p>"; } $line++; } } =cut # use the block for NEW blogger while($xml =~ m/(.*?)<\/title>.*?<link rel='(.*?)'.*?type='text\/html'.*?href='(.*?)'><\/link>/g) { if($2 eq "alternate") { if($3 eq "http://www.YOUR-DOMIAN.ie/news/index.html"){next;} # exclude item back to self if($line eq 0){print "<h4>"; } if($line gt 0){print "<p>"; } print "<a href=\"$3\">"; print "$1</a><br>"; if($line gt 0){print "<\/p>"; } $line++; } } print "<\/ul>"; print end_html;