Skip to content

Instantly share code, notes, and snippets.

@danhigham
Created April 21, 2011 11:38
Show Gist options
  • Save danhigham/934246 to your computer and use it in GitHub Desktop.
Save danhigham/934246 to your computer and use it in GitHub Desktop.
Hpricot script to extract sunrise and sunset dates from http://www.timeanddate.com/worldclock/astronomy.html
#!/usr/bin/ruby
require 'rubygems'
require 'open-uri'
require 'hpricot'
doc = Hpricot(open("http://www.timeanddate.com/worldclock/astronomy.html?n=136&month=12&year=2010&obj=sun&afl=-11&day=1"))
sunrise_rows = (doc/"table.spad tr")
sunrise_rows.each do |x|
puts "Date: #{(x/"td:eq(0)").text}"
puts "Sunrise: #{(x/"td:eq(1)").text}"
puts "Sunset: #{(x/"td:eq(2)").text}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment