Created
September 7, 2012 00:53
-
-
Save gkop/3662067 to your computer and use it in GitHub Desktop.
Scrape and parse Joseph the Starwatcher, featuring Wombat
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
# encoding: utf-8 | |
require 'wombat' | |
SIGNS = ["Aries", "Taurus", "Gemini", "Cancer", "Leo", "Virgo", "Libra", | |
"Scorpio", "Sagittarius", "Capricorn", "Aquarius", "Pisces"] | |
data = Wombat.crawl do | |
base_url "http://www.taosnet.com" | |
path "/starwatcher/rdoscrpt.html" | |
date "css=center" do |text| | |
Date.parse(text) | |
end | |
signs do | |
SIGNS.each do |sign| | |
send(sign, "css=center") do |t| | |
t.gsub(/\n/, '').gsub(/.*#{sign} …/, '').gsub(/\w+ ….*$/, '').strip | |
end | |
end | |
end | |
end | |
puts "Horoscopes for #{data["date"]}:" | |
data["signs"].each do |k, v| | |
puts "\n#{k}: #{v}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@felipecsl , neat gem! Any suggestions for a more concise or better way of meta-defining properties? (see line 19)