tiger1974

Project 4 - XML::RSS

May 22nd, 2012
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.40 KB | None | 0 0
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use LWP::Simple;
  5. use XML::RSS;
  6. use CGI;
  7. my $cgi = CGI->new;
  8. my $url = "http://feeds.feedburner.com/firehouse";
  9. #my $url = "feeds.feedburner.com/nixiepixel";
  10. my ($content,$stuff);
  11. my $rss = XML::RSS->new;
  12. $content = get($url);
  13. $rss->parse($content);
  14. print $cgi->header,
  15. $cgi->start_html();
  16. sub do_html {
  17.         my $res = shift;
  18. #       print <<"HTML";
  19. #       HTML
  20.         foreach my $item (@{$rss->{'items'}}) {
  21.                 print qq{<a href="$item->{'link'}">$item->{'title'}</a><br>\n$item->{'description'}};
  22.                 }
  23.         if ($rss->{'channel'}->{'copyright'}) {
  24. #               print <<"HTML";
  25.                 }
  26. #       HTML
  27.         print $stuff;
  28.         print "<p>$rss->{'channel'}->{'copyright'}</p>";
  29. #       HTML
  30.         if ($rss->{'image'}->{'link'}) {
  31. #               print <<"HTML";
  32.                 <p><a href="$rss->{'image'}->{'link'}"><img src="$rss->{'image'}->{'url'}" alt="$rss->{'image'}->{'title'}" border="0"
  33. #               HTML
  34.                 print qq{ width="$rss->{'image'}->{'width'}"}
  35.                 if $rss->{'image'}->{'width'};
  36.                 print qq{ height="$rss->{'image'}->{'height'}"}
  37.                 if $rss->{'image'}->{'height'};
  38.                 print "></a></center><p>\n";
  39.                 }
  40. "proj4.pl" 46L, 1119C                                                               19,1          Top
Advertisement
Add Comment
Please, Sign In to add comment