Skip to content

Instantly share code, notes, and snippets.

@citizen428
Created November 23, 2011 19:33
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save citizen428/1389652 to your computer and use it in GitHub Desktop.
Save citizen428/1389652 to your computer and use it in GitHub Desktop.
Create an Atom feed from the new Ruby repos page
require 'open-uri'
require 'nokogiri'
require 'builder'
html = open("https://github.com/languages/Ruby/created")
doc = Nokogiri::HTML.parse(html)
atom = Builder::XmlMarkup.new(:target => STDOUT, :indent => 2)
atom.instruct!
atom.feed "xmlns" => "http://www.w3.org/2005/Atom" do
atom.id "urn:citizen428:github:newrepos"
atom.updated Time.now.utc.iso8601(0)
atom.title "New GitHub Ruby Repos", :type => "text"
atom.link :rel => "self", :href => "/ruby_github.atom"
doc.xpath("//table[@class='repo']/tr/td[@class='title']/a").each do |title|
name = title.content
owner = title.at_xpath("../../td[@class='owner']/a").content
desc = title.at_xpath("../../following-sibling::tr/td[@class='desc']").content
date = Time.parse(title.at_xpath("../../td[@class='date']").content)
atom.entry do
atom.title "#{owner}: #{name}"
atom.author { atom.name owner }
atom.link "href" => "https://github.com#{title.attributes["href"].value}"
atom.id "urn:citizen428:github:#{owner}:#{name}"
atom.published date.utc.iso8601(0)
atom.updated date.utc.iso8601(0)
atom.content desc, :type => "html"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment