Skip to content

Instantly share code, notes, and snippets.

@jystewart
Created February 18, 2009 22:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jystewart/66591 to your computer and use it in GitHub Desktop.
Save jystewart/66591 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'hpricot'
require 'open-uri'
# Extract a list of currently available hotels for SxSWi
# and produce a simple list of "name - 1 person price - map URL"
# The intention was to then plot them on a map, but I found
# what I needed and moved on
doc = Hpricot(open("http://www.sxsw.com/hotels"))
hotel_list = doc.search("ul#hotel_list li")
options = hotel_list.collect do |item|
name = item.search("h1").inner_text
price = item.search(".amenities_pane table tr")[2].search('td:first').inner_text.split("/").first.strip
map = item.search("a")[2]['href']
"#{name} - #{price} - #{map}"
end
# Display alphabetically
puts options.sort { |a, b| a <=> b }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment