Reply to comment

rss2txt: RSS Headlines Output as Text

This is a script that takes an RSS URL as an argument, and emits the headlines. Potentially useful if you have a small text-reading device that doesn't handle HTML.


#! /usr/bin/perl

use XML::RSS;
use WWW::Curl::Easy;

my $curl = WWW::Curl::Easy->new();
$curl->setopt(CURLOPT_HEADER,0);
open DEVNULL,">/dev/null";
$curl->setopt(CURLOPT_WRITEHEADER, DEVNULL );
$curl->setopt(CURLOPT_URL, $ARGV[0] );
my $response_body;
open (my $fileb, ">", \$response_body);
$curl->setopt(CURLOPT_WRITEDATA,$fileb);
my $retcode = $curl->perform;

my $rss = new XML::RSS;
$rss->parse($response_body);

foreach my $item (@{$rss->{'items'}}) 
{
	print $item->{'title'}."\n\n";
}

close DEVNULL;

Reply

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <b> <dd> <dl> <dt> <i> <li> <ol> <u> <ul> <p> <br> <div> <pre> <code> <img><h1><h2><h3><h4> <blockquote>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

.