#!/usr/bin/perl -w use strict; $| = 1; ################################ # rss_2_0.pl # # URL: http://www.infocopter.com/perl/rss.html # Location: quartus # # Usage: # rss_2_0.pl [Options] rssinput.xml "3" >output_top3.html # my $VERSION = '0.05.02'; ################################ use XML::GDOME; use Unicode::String qw(latin1 utf8); # For Umlaute problems -> web_enc / toISO use Getopt::Long; # -- GLOBAL my $DEBUG = 0; my $do = my $i = 0; my %META = (); # -- Don't make a target _blank to this domains: my @HOME_DOMAINS = qw(infocopter.com pgate.net); my @getopt_args = ( 'd', # debug 'debug' , # debug mode for development support 'omit_tags=s' , # e.g. img,a,h1 'h', # help 'proxy=s', # proxy host 'v', # Verbose mode ); my %Options; Getopt::Long::config("noignorecase", "bundling"); print "\n"; &Usage() unless GetOptions(\%Options, @getopt_args); if ($Options{'d'} or $Options{'debug'}) { foreach (keys %Options) { print "- $_ = \"$Options{$_}\"\n"; } } $Options{'omit_tags'} ||= ''; my $doc = XML::GDOME->createDocFromURI($ARGV[0] || '/var/www/html/rss/xml/linuxjournal.xml'); my @nodes = $doc->findnodes("//*"); &main(); ############################################### sub main() { ############################################### my @row_color = (); $row_color[0] = 'white'; $row_color[1] = '#e9e9e9'; #print '
| ', scalar localtime, ' |
| ';
if (defined $hash_ref->{'url'}) {
print '',
' '; } } print ' |
| ';
}
my $title = $hash_ref->{'title'};
$title =~ s/’/'/g;
$title =~ s/é/\é/g;
$title =~ s/è/\è/g;
if (&isISO($title)) {
$title = &web_enc($title);
}
else {
$title = &web_enc(&toISO($title));
}
print '', $title, ' ', '', $hash_ref->{'pubDate'}, ' ', $description, ' ', "\n"; if ($hash_ref->{'category'}) { print '› ', $hash_ref->{'category'}, ' '; } (my $link_disp = $hash_ref->{'link'}) =~ s/^https?:\/\///i; $link_disp =~ s/^www\.//i; if (length($link_disp) > 60) { $link_disp = substr($link_disp, 0, 60) . '...'; } my $target = ' target="_blank"'; # default linking my $uarr = ' ↑'; foreach (@HOME_DOMAINS) { if ($hash_ref->{'link'} =~ /$_/) { $target = $uarr = ''; last; } } print "› {'link'}, '">', $link_disp, "$uarr "; print ' |
| ';
# foreach (keys %META) { print "$_ = $META{$_} "; } print ' ', $meta_row, ''; print ' |