Skip to content

Instantly share code, notes, and snippets.

@will
Created January 8, 2009 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save will/44876 to your computer and use it in GitHub Desktop.
Save will/44876 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
require "rubygems"
require "scrapi"
url =
"https://ui2web1.apps.uillinois.edu/BANPROD1/bwckschd.p_disp_detail_sched?term_in=120091&crn_in=43437"
seats = Scraper.define do
array :numbers
process "td.dddefault", :numbers=>:text
result :numbers
end
result = seats.scrape(URI.parse(url))
remaining_seats = result[3].to_i
message = "[#{Time.now}] -- #{remaining_seats} seats"
if remaining_seats > 0
require 'net/smtp'
name = "your name"
address = "email address"
msg = <<EOM
From: #{name} <#{address}>
To: #{name} <#{address}>
Subject: CLASS OPENING
#{message}
EOM
Net::SMTP.start("localhost") do |smtp|
smtp.send_message msg, address, address
end
end
File.open("~/seatcheck.log", "a") do |file|
file << "#{message}\n"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment