Archive for May, 2007

Hpricot - HTML parser for Ruby

May 27th, 2007

Hpricot is a very interesting lib to parse HTML. I’ll post here the example, just to check on the beauty of it from time to time…

require ‘hpricot’
require ‘open-uri’
# load the RedHanded home page
doc = Hpricot(open(””))
# change the CSS class on links
(doc/”span.entryPermalink”).set(”class”, “newLinks”)
# remove the sidebar
# print the altered HTML
puts doc

The lib is evolving, being added […]