Código html para pedir los feeds del rss:#!/usr/bin/ruby
require 'cgi'
require 'rss/1.0'
require 'rss/2.0'
require 'open-uri'
require 'rexml/document'
cgi = CGI.new
puts cgi.header
puts "<html><head><title>Agregador RSS</title><link href='estilo.css' rel='stylesheet' type='text/css'></head><body> <br>"
#Obtenemos las fuentes del url
fuentes=cgi.params['fuenteRSS']
codigo = "<br>"
#Para cada fuente extraemos el xml (rss) que lleva
fuentes.each do |feed|
content = ""
open(feed) do |s| content = s.read end
rss = RSS::Parser.parse(content, false)
#y mostramos tanto el título del canal como el propio url del feed
codigo += "<h1> Canal: " + rss.channel.title + "</h1><br>"
codigo += "<h2> Feed: " + feed + "</h2><br>"
#Y para cada noticia (item) del canal extraemos el link con su título y la fecha
rss.channel.items.each do |item|
codigo += "<a href=" + item.link + ">" + item.title + "</a> <br>"
codigo += "Fecha de publicación: " + item.pubDate.strftime("%d/%m/%Y a las %H:%M h") + "<br><br>"
end
end
#Mostramos todo el código
puts codigo
#Finalizamos la página HTML
puts "</body></html>"
<html>
<head>
</head>
<body>
<div id='resultado' style='border:solid;background:lightblue;padding:30px'>
<h1><b><i>Feeds RSS:</i></b></h1><p>
<FORM name=formulario"" ACTION="http://swecai.ugr.es/~tularis/P5/rss.cgi">
Fuente RSS 1: <INPUT name="fuenteRSS" size="50" value="http://rss.marca.com/rss/descarga.htm?data2=429"><BR>
Fuente RSS 2: <INPUT name="fuenteRSS" size="50" value="http://rss.marca.com/rss/descarga.htm?data2=428"><BR>
Fuente RSS 3: <INPUT name="fuenteRSS" size="50" value="http://rss.marca.com/rss/descarga.htm?data2=445"><BR>
Fuente RSS 4: <INPUT name="fuenteRSS" size="50" value="http://rss.marca.com/rss/descarga.htm?data2=447"><BR>
Fuente RSS 5: <INPUT name="fuenteRSS" size="50" value="http://rss.marca.com/rss/descarga.htm?data2=443"><BR>
<p><div id="botonSubmit" style='padding-left:50px'><INPUT TYPE=SUBMIT VALUE="Submit"></div</p>
</FORM>
</body>
</html>
Se puede probar aquí: probarla