in reply to Re^3: Trying to get an RSS to display
in thread Trying to get an RSS to display
#!/usr/bin/perl # RSS CGI Prog use strict; use warnings; use CGI; use XML::RSS; use LWP::Simple; use Data::Dumper; my $cgi = CGI->new; my $url = "http://feeds.feedburner.com/animals"; my $content; my $rss = XML::RSS->new; if ($url=~ /http:/i) { $content = get($url); die "Could not retrieve $url" unless $content; $rss->parse($content); } print $cgi->header, $cgi->start_html(-style=>"/css/cgi_lesson1.css",-title=>"This is + an RSS thingy."); print_html($rss); sub print_html { my $rss = shift; print <<"HTML"; <div class="container"><div class="header"><B><center><h2><a href="$rs +s->{'channel'}->{'link'}">$rss->{'channel'}->{'title'}</a></h2></cent +er></B> HTML if ($rss->{'image'}->{'link'}) { print <<"HTML"; <center> <p><a href="$rss->{'image'}->{'link'}"><img src="$rss->{'image'}->{'ur +l'}" alt="$rss->{'image'}->{'title'}" border="0" HTML print qq{ width="$rss->{'image'}->{'width'}"} if $rss->{'image'}->{'width'}; print qq{ height="$rss->{'image'}->{'height'}"} if $rss->{'image'}->{'height'}; print "></a></center><p></div>\n"; } print qq{<div class="content">}; foreach my $item (@{$rss->{'items'}}) { next unless defined($item->{'title'}) && defined($item->{'link'}); print qq{<a href="$item->{'link'}">$item->{'title'}</a><BR>\n$item +->{'description'}}; } if ($rss->{'channel'}->{'copyright'}) { print <<"HTML"; </div> <div class="footer"><center><p><sub>$rss->{'channel'}->{'copyright'}</ +sub></p></center> HTML } print <<"HTML"; </div></div> HTML } print $cgi->end_html;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Trying to get an RSS to display
by Anonymous Monk on Oct 27, 2011 at 21:20 UTC |