Skip to content

Instantly share code, notes, and snippets.

@gkop
Created September 7, 2012 00:53
Show Gist options
  • Save gkop/3662067 to your computer and use it in GitHub Desktop.
Save gkop/3662067 to your computer and use it in GitHub Desktop.
Scrape and parse Joseph the Starwatcher, featuring Wombat
# 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
@gkop
Copy link
Author

gkop commented Sep 7, 2012

@felipecsl , neat gem! Any suggestions for a more concise or better way of meta-defining properties? (see line 19)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment