<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: rss code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Thu, 24 Jul 2008 04:22:55 GMT</pubDate>
    <description>DZone Snippets: rss code</description>
    <item>
      <title>Seamlessly return a string from http or https feeds</title>
      <link>http://snippets.dzone.com/posts/show/5624</link>
      <description>// This class uses URI module to detect regular or secure links, and returns the response as a string, in my case to pass onto a feed parser like simple-rss. I'm working on a simple http authentication addon.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#beef.&lt;br /&gt;require 'net/http'&lt;br /&gt;require 'net/https'&lt;br /&gt;require 'simple-rss'&lt;br /&gt;&lt;br /&gt;class SeamlessFeed&lt;br /&gt;  def initialize(url,user=nil,password=nil)&lt;br /&gt;    @url = URI.parse(url)&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  def output&lt;br /&gt;    if self.is_secure?&lt;br /&gt;      http = Net::HTTP.new(@url.host, 443)&lt;br /&gt;      http.use_ssl = true&lt;br /&gt;      http.start do |http|&lt;br /&gt;        request = Net::HTTP::Get.new(@url.path)&lt;br /&gt;        @response = http.request(request)&lt;br /&gt;        @response.value&lt;br /&gt;      end&lt;br /&gt;    else&lt;br /&gt;      @response = Net::HTTP.get_response(@url) #Why can't they all be like this, eh?&lt;br /&gt;    end&lt;br /&gt;    return @response.body&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  def is_readable?&lt;br /&gt;    feed = SimpleRSS.parse(self.output)&lt;br /&gt;    return true unless feed.channel.items.size &lt; 1&lt;br /&gt;  rescue SimpleRSSError&lt;br /&gt;    return false&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;protected&lt;br /&gt;  def is_secure?&lt;br /&gt;    @url.scheme == 'https'&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 09 Jun 2008 20:15:15 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5624</guid>
      <author>m0wfo (Chris Mowforth)</author>
    </item>
    <item>
      <title>PHP&#12450;&#12483;&#12503;&#12525;&#12540;&#12480;&#12540; RSS&#27231;&#33021;</title>
      <link>http://snippets.dzone.com/posts/show/5142</link>
      <description>PHP&#12450;&#12483;&#12503;&#12525;&#12540;&#12480;&#12540; RSS&#27231;&#33021;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;/**** PHP&#12450;&#12483;&#12503;&#12525;&#12540;&#12480;&#12540; RSS&#27231;&#33021; ***&lt;br /&gt; * by &#9670;RTphpfqies&lt;br /&gt; ****/&lt;br /&gt;&lt;br /&gt;  $title	= 'PHP&#12450;&#12483;&#12503;&#12525;&#12540;&#12480;&#12540;';&lt;br /&gt;  $logfile	= "./log/upup.log";	//&#12525;&#12464;&#12501;&#12449;&#12452;&#12523;&#21517;&#65288;&#22793;&#26356;&#12377;&#12427;&#20107;&#65289;&lt;br /&gt;  $updir 	= "./log/";	//&#12450;&#12483;&#12503;&#29992;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;(&#22793;&#26356;&#12377;&#12427;&#22580;&#21512;&#12399;&#12289;35.48.50&#34892;&#12418;&#22793;&#26356;&#65289;&lt;br /&gt;  $prefix	= '';		//&#25509;&#38957;&#35486;&#65288;up001.txt,up002.jpg&#12394;&#12425;up&#65289;&lt;br /&gt;  $page_def	= 20;		//RSS&#12398;&#34920;&#31034;&#34892;&#25968;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;function FormatByte($size){//&#12496;&#12452;&#12488;&#12398;&#12501;&#12457;&#12540;&#12510;&#12483;&#12488;&#65288;B&#8594;kB&#65289;&lt;br /&gt;  if($size == 0)			$format = "";&lt;br /&gt;  else if($size &lt;= 1024)		$format = $size."B";&lt;br /&gt;  else if($size &lt;= (1024*1024))		$format = sprintf ("%dKB",($size/1024));&lt;br /&gt;  else if($size &lt;= (10*1024*1024))	$format = sprintf ("%.2fMB",($size/(1024*1024)));&lt;br /&gt;  else					$format = $size."B";&lt;br /&gt;&lt;br /&gt;  return $format;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;error_reporting(0);&lt;br /&gt;$base_dir = 'http://'.$_SERVER['HTTP_HOST'].str_replace('\\','/', dirname($_SERVER['SCRIPT_NAME'])); if(substr($base_dir,-1) != '/') $base_dir .= '/'; // URL&lt;br /&gt;	header('Content-Type: text/xml;charset=shift-jis');&lt;br /&gt;echo'&lt;?xml version="1.0" encoding="shift-jis"?&gt;&lt;br /&gt;&lt;rss version="2.0"&gt;&lt;br /&gt;&lt;channel&gt;&lt;br /&gt;&lt;title&gt;'.$title.'&lt;/title&gt;&lt;br /&gt;&lt;link&gt;'.$base_dir.'&lt;/link&gt;&lt;br /&gt;&lt;description&gt;'.$title.'&lt;/description&gt;&lt;br /&gt;&lt;language&gt;ja&lt;/language&gt;&lt;br /&gt;&lt;generator&gt;PHP&#12450;&#12483;&#12503;&#12525;&#12540;&#12480;&#12540; RSS&#27231;&#33021;&lt;/generator&gt;';&lt;br /&gt;&lt;br /&gt;$lines = file($logfile);&lt;br /&gt;for($i = 0; $i &lt; $page_def; $i++){&lt;br /&gt;  if($lines[$i]=="") continue;&lt;br /&gt;  list($id,$ext,$com,$host,$now,$size,$mtype,$pas,$orig,)=explode("\t",$lines[$i]);&lt;br /&gt;  $fsize = FormatByte($size);&lt;br /&gt;&lt;br /&gt;  $filename = $prefix.$id.".$ext";&lt;br /&gt;  $target = $updir.$filename;&lt;br /&gt;&lt;br /&gt;  echo '&lt;item&gt;&lt;br /&gt;	&lt;title&gt;'.$filename.' - '.$orig.' ('.$fsize.')&lt;/title&gt;&lt;br /&gt;	&lt;link&gt;'.$base_dir.$target.'&lt;/link&gt;&lt;br /&gt;	&lt;description&gt;&lt;br /&gt;	&lt;![CDATA[&lt;br /&gt;'.$com.'&lt;br /&gt;	]]&gt;&lt;br /&gt;	&lt;/description&gt;&lt;br /&gt;	&lt;pubDate&gt;'.$now.'&lt;/pubDate&gt;&lt;br /&gt;&lt;/item&gt;&lt;br /&gt;';&lt;br /&gt;  }&lt;br /&gt;echo '&lt;/channel&gt;&lt;br /&gt;&lt;/rss&gt;';&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 15 Feb 2008 12:53:23 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5142</guid>
      <author>roytam1 (Roy Tam)</author>
    </item>
    <item>
      <title>Simple Ruby Snarl RSS alerter</title>
      <link>http://snippets.dzone.com/posts/show/5092</link>
      <description>This simple Ruby program will send a Snarl alert when a new post is added to a feed. Assumes your Snarl command line tool is named "snarl.exe" and in your PATH.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;require 'rss/1.0'&lt;br /&gt;require 'rss/2.0'&lt;br /&gt;require 'open-uri'&lt;br /&gt;&lt;br /&gt;def snarl(title, msg)&lt;br /&gt;  # This part actually sends the notification.&lt;br /&gt;  # Change "snarl" to your snarl command line tool if you have problems&lt;br /&gt;  system "snarl /M \"#{title}\" \"#{msg}\""&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;source = ARGV[0]&lt;br /&gt;content = ''&lt;br /&gt;open(source) { |s| content = s.read }&lt;br /&gt;rss = RSS::Parser.parse(content, false)&lt;br /&gt;puts rss.channel.title&lt;br /&gt;puts rss.channel.link&lt;br /&gt;puts rss.channel.description&lt;br /&gt;&lt;br /&gt;last_item = nil&lt;br /&gt;&lt;br /&gt;while true&lt;br /&gt;  puts "Checking for updates..."&lt;br /&gt;  open(source) { |s| content = s.read }&lt;br /&gt;  rss = RSS::Parser.parse(content, false)&lt;br /&gt;  if last_item == rss.items[0]&lt;br /&gt;    sleep 5*60*1000&lt;br /&gt;  else&lt;br /&gt;    last_item = rss.items[0]&lt;br /&gt;    snarl last_item.title + " (#{rss.channel.title})", last_item.description.gsub(/&lt;\/?[^&gt;]*&gt;/, "")&lt;br /&gt;    sleep 10*60*1000&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sat, 02 Feb 2008 23:02:17 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5092</guid>
      <author>zuwiki (Mike Zink)</author>
    </item>
    <item>
      <title>RSS output of a Prologue post</title>
      <link>http://snippets.dzone.com/posts/show/5053</link>
      <description>// This is how Prologue outputs a post&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;item&gt;&lt;br /&gt;		&lt;title&gt;&lt;/title&gt;&lt;br /&gt;		&lt;link&gt;http://localhost/wordpress/?p=3&lt;/link&gt;&lt;br /&gt;		&lt;comments&gt;http://localhost/wordpress/?p=3#comments&lt;/comments&gt;&lt;br /&gt;		&lt;pubDate&gt;Tue, 29 Jan 2008 23:54:15 +0000&lt;/pubDate&gt;&lt;br /&gt;&lt;br /&gt;		&lt;dc:creator&gt;admin&lt;/dc:creator&gt;&lt;br /&gt;		&lt;br /&gt;		&lt;category&gt;&lt;![CDATA[Uncategorized]]&gt;&lt;/category&gt;&lt;br /&gt;&lt;br /&gt;		&lt;category&gt;&lt;![CDATA[welcome]]&gt;&lt;/category&gt;&lt;br /&gt;&lt;br /&gt;		&lt;guid isPermaLink="false"&gt;http://localhost/wordpress/?p=3&lt;/guid&gt;&lt;br /&gt;		&lt;description&gt;&lt;![CDATA[Pretty cool, here&amp;#8217;s the Twitta!]]&gt;&lt;/description&gt;&lt;br /&gt;			&lt;br /&gt;                &lt;content:encoded&gt;&lt;![CDATA[&lt;p&gt;Pretty cool, here&amp;#8217;s the Twitta!&lt;/p&gt;]]&gt;&lt;/content:encoded&gt;&lt;br /&gt;			&lt;wfw:commentRss&gt;http://localhost/wordpress/?feed=rss2&amp;p=3&lt;/wfw:commentRss&gt;&lt;br /&gt;&lt;br /&gt;&lt;/item&gt;&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 30 Jan 2008 00:25:57 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5053</guid>
      <author>als (alex)</author>
    </item>
    <item>
      <title>Transforming XML into RSS</title>
      <link>http://snippets.dzone.com/posts/show/5040</link>
      <description>Using the previous &lt;a href="http://snippets.dzone.com/posts/show/5039"&gt;code snippet which prepared an XML file&lt;/a&gt; it can now be transformed to RSS using the XSL below.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;file: gang2rss.xsl&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"&gt;&lt;br /&gt;&lt;br /&gt;	&lt;xsl:output method="xml" encoding="iso-8859-1" indent="yes"  /&gt;&lt;br /&gt;&lt;br /&gt;	&lt;xsl:template match="rss"&gt;&lt;br /&gt;&lt;br /&gt;		&lt;rss version="2.0"&gt;	&lt;br /&gt;		&lt;channel&gt;&lt;br /&gt;		&lt;title&gt;The Gang&lt;/title&gt;&lt;br /&gt;		&lt;link&gt;http://newsgang.net/audio/&lt;/link&gt;&lt;br /&gt;		&lt;description&gt;The Gang podcast&lt;/description&gt;&lt;br /&gt;&lt;br /&gt;  	&lt;language&gt;en&lt;/language&gt;&lt;br /&gt;&lt;br /&gt;	&lt;xsl:apply-templates select="item" /&gt;&lt;br /&gt;&lt;br /&gt;		&lt;/channel&gt;&lt;br /&gt;		&lt;/rss&gt;&lt;br /&gt;&lt;br /&gt;	&lt;/xsl:template&gt;&lt;br /&gt;&lt;br /&gt;	&lt;xsl:template match="item"&gt;&lt;br /&gt;&lt;br /&gt;	&lt;item&gt;&lt;br /&gt;		&lt;title&gt;&lt;xsl:value-of select="title"/&gt;&lt;/title&gt;&lt;br /&gt;		&lt;link&gt;http://newsgang.net&lt;xsl:value-of select="href"/&gt;&lt;/link&gt;&lt;br /&gt;		&lt;description&gt;&lt;xsl:value-of select="date"/&gt;&lt;/description&gt;&lt;br /&gt;		&lt;enclosure&gt;http://newsgang.net&lt;xsl:value-of select="href_audio"/&gt;&lt;/enclosure&gt;&lt;br /&gt;	&lt;/item&gt;&lt;br /&gt;&lt;br /&gt;	&lt;/xsl:template&gt;	&lt;br /&gt;&lt;br /&gt;&lt;/xsl:stylesheet&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;To transform the xsl file from the command-line you would type:&lt;br /&gt;&lt;br /&gt;xsltproc gang2rss.xsl thegang_rss.xml&lt;br /&gt;&lt;br /&gt;output&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;?xml version="1.0" encoding="iso-8859-1"?&gt;&lt;br /&gt;&lt;rss version="2.0"&gt;&lt;br /&gt;  &lt;channel&gt;&lt;br /&gt;    &lt;title&gt;The Gang&lt;/title&gt;&lt;br /&gt;    &lt;link&gt;http://newsgang.net/audio/&lt;/link&gt;&lt;br /&gt;    &lt;description&gt;The Gang podcast&lt;/description&gt;&lt;br /&gt;    &lt;language&gt;en&lt;/language&gt;&lt;br /&gt;    &lt;item&gt;&lt;br /&gt;      &lt;title&gt;TheGangXII-II&lt;/title&gt;&lt;br /&gt;      &lt;link&gt;http://newsgang.net/gangitem/id=6501&lt;/link&gt;&lt;br /&gt;      &lt;description&gt;Jan 25&lt;/description&gt;&lt;br /&gt;      &lt;enclosure&gt;http://newsgang.net/gangitem/id=6501&amp;amp;from=audio&lt;/enclosure&gt;&lt;br /&gt;    &lt;/item&gt;&lt;br /&gt;    &lt;item&gt;&lt;br /&gt;      &lt;title&gt;TheGangXII-I&lt;/title&gt;&lt;br /&gt;      &lt;link&gt;http://newsgang.net/gangitem/id=6499&lt;/link&gt;&lt;br /&gt;      &lt;description&gt;Jan 25&lt;/description&gt;&lt;br /&gt;      &lt;enclosure&gt;http://newsgang.net/gangitem/id=6499&amp;amp;from=audio&lt;/enclosure&gt;&lt;br /&gt;    &lt;/item&gt;&lt;br /&gt;    &lt;item&gt;&lt;br /&gt;      &lt;title&gt;NewsGangLive01.24.08&lt;/title&gt;&lt;br /&gt;      &lt;link&gt;http://newsgang.net/gangitem/id=6445&lt;/link&gt;&lt;br /&gt;      &lt;description&gt;Jan 24&lt;/description&gt;&lt;br /&gt;      &lt;enclosure&gt;http://newsgang.net/gangitem/id=6445&amp;amp;from=audio&lt;/enclosure&gt;&lt;br /&gt;    &lt;/item&gt;&lt;br /&gt;    &lt;item&gt;&lt;br /&gt;      &lt;title&gt;NewsGangLiveII&lt;/title&gt;&lt;br /&gt;      &lt;link&gt;http://newsgang.net/gangitem/id=6377&lt;/link&gt;&lt;br /&gt;      &lt;description&gt;Jan 23&lt;/description&gt;&lt;br /&gt;      &lt;enclosure&gt;http://newsgang.net/gangitem/id=6377&amp;amp;from=audio&lt;/enclosure&gt;&lt;br /&gt;    &lt;/item&gt;&lt;br /&gt;  &lt;/channel&gt;&lt;br /&gt;&lt;/rss&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Note: The enclosure url in this example does not reference the media file directly.&lt;br /&gt;&lt;br /&gt;see also: http://en.wikipedia.org/wiki/RSS_(file_format)</description>
      <pubDate>Sun, 27 Jan 2008 16:21:37 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5040</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
    <item>
      <title>Scrape an XHTML document using Ruby</title>
      <link>http://snippets.dzone.com/posts/show/5039</link>
      <description>A simple Ruby script to scrape an XHTML file with the selected content being saved to an xml file ready for transformation into an RSS feed.  This example uses the XHTML file from http://newsgang.net/audio/ which is then saved locally as 'thegang.xml'.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/usr/bin/ruby&lt;br /&gt;# file: thegang.rb&lt;br /&gt;&lt;br /&gt;require 'rexml/document'&lt;br /&gt;include REXML&lt;br /&gt;&lt;br /&gt;class TheGang&lt;br /&gt;  def initialize()&lt;br /&gt;  end&lt;br /&gt;  &lt;br /&gt;  def rssify()&lt;br /&gt;    file = File.new('thegang.xml','r')&lt;br /&gt;    doc = Document.new(file)&lt;br /&gt;    rss_doc = Document.new&lt;br /&gt;    root = Element.new('rss')&lt;br /&gt;    rss_doc.add_element(root)&lt;br /&gt;    &lt;br /&gt;    doc.root.elements.each("body/div/ul/li/h2/a") do |node|    &lt;br /&gt;      o_rssitem = Element.new('item')&lt;br /&gt;      o_li = node.parent.parent&lt;br /&gt;      &lt;br /&gt;      o_rsstitle = Element.new('title')&lt;br /&gt;      o_rsstitle.text = node.text.gsub(/[\n,' ']/,'')&lt;br /&gt;      o_rssitem.add_element(o_rsstitle)&lt;br /&gt;      &lt;br /&gt;      o_rsshref_audio = Element.new('href_audio')&lt;br /&gt;      o_rsshref_audio.text = node.attributes.get_attribute('href').to_s.gsub('amp;&amp;','')      &lt;br /&gt;      o_rssitem.add_element(o_rsshref_audio)&lt;br /&gt;      &lt;br /&gt;      o_rsshref = Element.new('href')&lt;br /&gt;      o_rsshref.text = o_rsshref_audio.text.gsub('&amp;amp;from=audio','')      &lt;br /&gt;      o_rssitem.add_element(o_rsshref)&lt;br /&gt;      &lt;br /&gt;      o_rssdate = Element.new('date')&lt;br /&gt;      o_rssdate.text = "#{o_li.elements["p/span[1]"].text} #{o_li.elements["p/span[2]"].text}"&lt;br /&gt;      o_rssitem.add_element(o_rssdate)&lt;br /&gt;      rss_doc.root.add_element(o_rssitem)&lt;br /&gt;      &lt;br /&gt;    end&lt;br /&gt;&lt;br /&gt;    file = File.new('thegang_rss.xml','w')&lt;br /&gt;    file.puts rss_doc&lt;br /&gt;    file.close&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;if __FILE__ == $0&lt;br /&gt;  gang = TheGang.new&lt;br /&gt;  gang.rssify&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;see also: www.dapper.net&lt;br /&gt;&lt;br /&gt;output (extract)&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;rss&gt;&lt;br /&gt;  &lt;item&gt;&lt;title&gt;TheGangXII-II&lt;/title&gt;&lt;href_audio&gt;/gangitem/id=6501&amp;amp;from=audio&lt;/href_audio&gt;&lt;href&gt;/gangitem/id=6501&lt;/href&gt;&lt;date&gt;Jan 25&lt;/date&gt;&lt;/item&gt;&lt;br /&gt;  &lt;item&gt;&lt;title&gt;TheGangXII-I&lt;/title&gt;&lt;href_audio&gt;/gangitem/id=6499&amp;amp;from=audio&lt;/href_audio&gt;&lt;href&gt;/gangitem/id=6499&lt;/href&gt;&lt;date&gt;Jan 25&lt;/date&gt;&lt;/item&gt;&lt;br /&gt;  &lt;item&gt;&lt;title&gt;NewsGangLive01.24.08&lt;/title&gt;&lt;href_audio&gt;/gangitem/id=6445&amp;amp;from=audio&lt;/href_audio&gt;&lt;href&gt;/gangitem/id=6445&lt;/href&gt;&lt;date&gt;Jan 24&lt;/date&gt;&lt;/item&gt;&lt;br /&gt;  &lt;item&gt;&lt;title&gt;NewsGangLiveII&lt;/title&gt;&lt;href_audio&gt;/gangitem/id=6377&amp;amp;from=audio&lt;/href_audio&gt;&lt;href&gt;/gangitem/id=6377&lt;/href&gt;&lt;date&gt;Jan 23&lt;/date&gt;&lt;/item&gt;&lt;br /&gt;  ...&lt;br /&gt;&lt;/rss&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 27 Jan 2008 14:09:24 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5039</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
    <item>
      <title>RSS Feed for DZone Snippets Comments</title>
      <link>http://snippets.dzone.com/posts/show/5031</link>
      <description>&lt;a href="http://feed43.com/8055673348816228.xml"&gt;http://feed43.com/8055673348816228.xml&lt;/a&gt;</description>
      <pubDate>Wed, 23 Jan 2008 14:23:09 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5031</guid>
      <author>timmorgan (Tim Morgan)</author>
    </item>
    <item>
      <title>Archive Flagged Items from NetNewsWire into Yojimbo</title>
      <link>http://snippets.dzone.com/posts/show/5001</link>
      <description>This lil Ruby-OSA script will allow you to import your "Flagged Items" in NetNewsWire as Web Archive Items in Yojimbo. Thus allowing you to save RSS articles for off-line viewing/storage.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/usr/local/bin/ruby&lt;br /&gt;['rubygems', 'rbosa'].each {|lib| require lib}&lt;br /&gt;nnw = OSA.app('NetNewsWire')&lt;br /&gt;yojimbo = OSA.app('Yojimbo')&lt;br /&gt;&lt;br /&gt;nnw.subscriptions.find { |s| s if s.display_name == 'Flagged Items' }.headlines.each do |article|&lt;br /&gt;  unless yojimbo.web_archive_items.map { |f| f.source_url }.include?(article.url)&lt;br /&gt;    archived = yojimbo.make(OSA::Yojimbo::WebArchiveItem, &lt;br /&gt;                            article.url, &lt;br /&gt;                            :name =&gt; article.title)&lt;br /&gt;    # Adjust this for slower/faster bandwidth connections (or your feeling lucky, punk)&lt;br /&gt;    sleep(5)&lt;br /&gt;    # Uncomment below to remove the flagged items upon successfully archiving&lt;br /&gt;    # if archived.name == 'untitled' &amp;&amp; archived.source_url.empty?&lt;br /&gt;    #   puts "!!! #{article.title} does not look to be imported !!!"&lt;br /&gt;    # else&lt;br /&gt;    #   article.delete&lt;br /&gt;    # end&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 18 Jan 2008 04:02:07 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5001</guid>
      <author>justinwr (Justin R)</author>
    </item>
    <item>
      <title>A simple RSS Reader and Podcatcher</title>
      <link>http://snippets.dzone.com/posts/show/4713</link>
      <description>Written in Ruby this class reads an RSS feed and downloads the latest enclosure if it exists.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;require 'rss/1.0'&lt;br /&gt;require 'rss/2.0'&lt;br /&gt;require 'open-uri'&lt;br /&gt;require 'open-uri'&lt;br /&gt;&lt;br /&gt;class Rssreader&lt;br /&gt;  def initialize(url)&lt;br /&gt;    source = url # url or local file&lt;br /&gt;    content = "" # raw content of rss feed will be loaded here&lt;br /&gt;    open(source) do |s| content = s.read end&lt;br /&gt;    @rss = RSS::Parser.parse(content, false)&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  # returns the first 3 titles from the rss feed&lt;br /&gt;  def get_summary()&lt;br /&gt;    buffer = '['&lt;br /&gt;    for i in 0..2&lt;br /&gt;      buffer += @rss.items[i.to_i].title + ' | '&lt;br /&gt;    end      &lt;br /&gt;    buffer.slice(0,buffer.length-3) + ']'&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  def enclosure?&lt;br /&gt;    @rss.items.to_s.scan('&lt;enclosure').length &gt; 0&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  def get_enclosure_url&lt;br /&gt;    enclosure = @rss.items[0].enclosure&lt;br /&gt;    enclosure.url&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  def rwget(url, filename)&lt;br /&gt;    file = File.new(filename, 'w')&lt;br /&gt;    file.puts open(url, 'User-Agent' =&gt; 'Ruby-wget').read&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  def download_enclosure()&lt;br /&gt;    if self.enclosure? then&lt;br /&gt;      enclosure_url = self.get_enclosure_url()&lt;br /&gt;      local_filename = File.basename(enclosure_url)&lt;br /&gt;      #puts local_filename&lt;br /&gt;      if not File.exist?(local_filename) then&lt;br /&gt;        puts 'downloading enclosure ...'&lt;br /&gt;        self.rwget(enclosure_url, local_filename)&lt;br /&gt;        puts 'download completed'&lt;br /&gt;      else&lt;br /&gt;        puts 'enclosure downloaded already'&lt;br /&gt;      end&lt;br /&gt;    end&lt;br /&gt;  end    &lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;if __FILE__ == $0&lt;br /&gt;  url = "http://mysite.com/gwd/feed/lugradio.rss"&lt;br /&gt;  rss = Rssreader.new(url)&lt;br /&gt;  puts rss.get_summary()&lt;br /&gt;  rss.download_enclosure()&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 29 Oct 2007 23:28:18 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4713</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
    <item>
      <title>Twitter bot weatherlisbon</title>
      <link>http://snippets.dzone.com/posts/show/4159</link>
      <description>This little bash script shows how to use curl, grep, tail, sed and perl one-liners in order to compose a bleeding-edge twitter bot.&lt;br /&gt;This one returns daily weather forecasts for Lisbon city based on the BBC weather forecast rss feed.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#! /bin/sh&lt;br /&gt;&lt;br /&gt;#Goto here&lt;br /&gt;here=/home/guillaume/Personal&lt;br /&gt;cd $here&lt;br /&gt;&lt;br /&gt;#BBC Lisbon weather id&lt;br /&gt;id=0048&lt;br /&gt;&lt;br /&gt;#BBC weather RSS feed address&lt;br /&gt;feed="http://feeds.bbc.co.uk/weather/feeds/rss/5day/world/${id}.xml"&lt;br /&gt;&lt;br /&gt;#City&lt;br /&gt;city=lisbon&lt;br /&gt;&lt;br /&gt;#temporary file&lt;br /&gt;file="weather${city}"&lt;br /&gt;&lt;br /&gt;#Weather twitter bot&lt;br /&gt;twitbot=weatherlisbon:*******&lt;br /&gt;&lt;br /&gt;#Timestamp the log file&lt;br /&gt;echo .&gt;&gt; $file.log&lt;br /&gt;date &gt;&gt; $file.log&lt;br /&gt;&lt;br /&gt;#Read the RSS feed and filter it&lt;br /&gt;curl $feed | grep 'title' | tail -n 1 | perl -wlne'm/title&gt;(.*)&lt;\/title/i &amp;&amp; print $1' | sed -e "s/&amp;#xB0;//g" &gt; $file.txt&lt;br /&gt;&lt;br /&gt;#Read the forecast into a weather variable&lt;br /&gt;read weather &lt; $file.txt&lt;br /&gt;&lt;br /&gt;#Twit the weather variable away&lt;br /&gt;curl --basic --user $twitbot --data status="$weather" http://twitter.com/statuses/update.xml &gt;&gt; $file.log&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 18 Jun 2007 21:37:40 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4159</guid>
      <author>griflet (guillaume riflet)</author>
    </item>
  </channel>
</rss>
