Skip to content

Instantly share code, notes, and snippets.

@soh335
Created June 6, 2009 13:04
Show Gist options
  • Save soh335/124842 to your computer and use it in GitHub Desktop.
Save soh335/124842 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'nokogiri'
require 'mechanize'
require 'ruby-growl'
url = 'https://wellness.sfc.keio.ac.jp/v3/pc.php?page=top&limit=9999'
agent = WWW::Mechanize.new
body = agent.get(url).body
html = Nokogiri::HTML.parse(body, nil, 'EUC-JP')
target = ['ウェルネス', 'ソフトテニス', 'サッカー']
growl = Growl.new('localhost', 'wellness_rb', ['event1', 'event2'], nil, '')
html.xpath('//div[@class="main"]/table[@class="cool"]/tr').each do |tag|
if target.include?(tag.xpath('td[3]').text)
text = String.new
tag.xpath('td').each do |node|
text = text + node.text + ':' unless node.text.empty?
end
growl.notify('event1', 'wellness_rb', text.chop)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment