Created
December 3, 2011 22:38
-
-
Save danneu/1428374 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 'open-uri' | |
require 'nokogiri' | |
zipcode = ARGV[0] || 78705 | |
url = "http://www.weather.com/weather/hourbyhour/graph/#{zipcode}" | |
doc = Nokogiri::HTML(open(url)) | |
raise('Zipcode not found') if /can't find the page you requested/ =~ doc.text | |
hours = doc.css('.hbhWxHour') | |
hours.each do |hour| | |
time = hour.css('.hbhWxTime').text | |
temp = hour.css('.hbhWxTemp').text | |
precip = /\d*[%]/.match hour.css('.hbhWxPrecip').text | |
puts "%5s: %6s (%s)\n" % [time, temp, precip] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment