Skip to content

Instantly share code, notes, and snippets.

@MelanieS
Created July 9, 2014 20:15
Show Gist options
  • Save MelanieS/63b53510df7964dc87ea to your computer and use it in GitHub Desktop.
Save MelanieS/63b53510df7964dc87ea to your computer and use it in GitHub Desktop.
PNC course tracker
#Purdue North Central doesn't have waitlists, but you can get notified of seat availability with this app
require 'rubygems'
require 'open-uri'
require 'hpricot'
require 'twilio-ruby'
availability = 0
puts "Enter the CRN for the PNC course you would like to track:"
crn = gets.chomp.to_s
url = "https://fusion-ssbprod.pnc.edu:8910/dbServer_prod/bwckschd.p_disp_detail_sched?term_in=201510&crn_in=#{crn}"
while availability == 0
sleep 10
doc = open(url) { |f| Hpricot(f) }
course_stats = (doc/"table//table//td").collect do |k|
k.inner_html.split(',')
end.flatten.compact
availability = course_stats[3].to_i
if availability == 0
puts "There are no available seats."
puts "Rechecking in 10 seconds."
elsif availability == 1
puts "There is one available seat."
else
puts "There are #{availability} seats available."
end
if availability > 0
account_sid = "000000000000000" #App sid
auth_token = "000000000000000" #Auth token
client = Twilio::REST::Client.new account_sid, auth_token
#enter app phone number here
from = "+10000000000"
recipients = {
#enter recipient phone numbers and names here
"+100000000000" => "Melanie"
}
recipients.each do |key, value|
client.account.messages.create(
:from => from,
:to => key,
:body => "Hey #{value}, there is space available in that course!"
)
puts "Sent message to #{value}"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment