Skip to content

Instantly share code, notes, and snippets.

@soh335
Created June 29, 2009 04:41
Show Gist options
  • Save soh335/137467 to your computer and use it in GitHub Desktop.
Save soh335/137467 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'mechanize'
require 'ruby-growl'
growl = Growl.new('localhost', 'wellness_rb', ['event1', 'event2'], nil, '')
url = 'https://wellness.sfc.keio.ac.jp/v3/'
agent = WWW::Mechanize.new
page = agent.get(url)
form = page.forms[0]
form.password = 'username'
form.login = 'password'
page = agent.submit(form)
array = Array.new
page.links.each do |link|
if /reserve/ =~ link.href && /mode=select/ !~ link.href
page = link.click
break
end
end
page.links.each do |link|
if /20090713/ =~ link.href
page = link.click
break
end
end
value = 0
page.search('//table[@class="cool"]/tr').each do |node|
if node.xpath('td[3]').text == '気功' && node.xpath('td[1]').text == '5限' && node.xpath('td[8]').text != '0'
value = node.xpath('td[9]/input')[0].attribute('value')
pp 'value:' + value.to_s
break
end
end
if value != 0
page.forms[0].radiobuttons.each do |c|
if c.value == value.to_s
c.check
pp c
break
end
end
page.forms[0].submit
growl.notify('event1', 'wellness_rb', 'done')
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment