Created
February 18, 2009 22:33
-
-
Save jystewart/66591 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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