This post originated from an RSS feed registered with Ruby Buzz
by Adam Green.
Original Post: Automatic OPML reading list from Tech Memeorandum
Feed Title: ruby.darwinianweb.com
Feed URL: http://www.nemesis-one.com/rss.xml
Feed Description: Adam Green's Ruby development site
This new script reads my XML list of Tech Memeorandum blogs and generates an OPML file with the matching RSS feeds. I do some simple RSS feed autodiscovery in each blog to find the feed. What this latest project really proves is that I don't actually know how to use regular expressions. If I did, I could probably condense this script down to a few lines. Anyway, it works, and maybe I'll get around to reading up on regex someday. The script is running on my mashup blog, and the resulting OPML file is updated every hour and placed here. You can grab the file once or subscribe to it as a reading list in your aggregator. Please let me know if you make any improvements to the script.
tmopml.rb
#! /usr/bin/ruby # tmopml.rb # Create an OPML reading list based on a list of # blogs cited on http://tech.memeorandum.com. # # Copyright (C) 2006 Adam Green # http://mashup.darwinianweb.com, adam AT darwinianweb DOT com # This program is distributed under the same license as Ruby. # require "open-uri" require "rexml/document" include REXML
# Open the list of blogs maintained at # http://mashup.darwinianweb.com/projects/tmblogs/tmblogs.xml doc = Document.new(File.read("public_html/projects/tmblogs/tmblogs.xml")) doc.elements.each("tmblogs/blog") do |blog| title = blog.elements["title"].text htmlurl = blog.elements["htmlUrl"].text
begin # Get the blog page's text. page = open(htmlurl) pagetext = page.read page.close
# Pull out all the link tags. feedfound = false pagetext.scan(/<link.*?>/i).each do |tag|
# clean up the tag. tag = tag.delete(" ") tag = tag.downcase
# Find the first feed link. if tag.match(('rel=\"alternate\"') && ('application\/rss\+xml'||'text\/xml'||'application\/atom\+xml'||'application\/x.atom\+xml'||'application\/x-atom\+xml') ) && (not feedfound)