-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscan.rb
47 lines (34 loc) · 1.67 KB
/
scan.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
require 'HTTParty' #Sends HTTP requests
require 'Nokogiri'
class Scraper
attr_accessor :parse_page
def initialize(link)
doc = HTTParty.get(link)
@parse_page = Nokogiri::HTML(doc)
end
def get_seats
avSeats = parse_page.css("tr").css(".dddefault").css("td:nth-child(4)").children.map { |seats| seats.text }.compact
end
classes = { "Web dev" => "https://banner.bsu.edu/ssbprod/bwckschd.p_disp_detail_sched?term_in=201910&crn_in=30024",
"Theory of Comp" => "https://banner.bsu.edu/ssbprod/bwckschd.p_disp_detail_sched?term_in=201910&crn_in=21805",
"Programming Languages" => "https://banner.bsu.edu/ssbprod/bwckschd.p_disp_detail_sched?term_in=201910&crn_in=30020",
"Operating Systems" => "https://banner.bsu.edu/ssbprod/bwckschd.p_disp_detail_sched?term_in=201910&crn_in=30028",
"Business Info Systems" => "https://banner.bsu.edu/ssbprod/bwckschd.p_disp_detail_sched?term_in=201910&crn_in=24910"
}
puts "---------------------------------------------------"
puts "---\t Class Seat Tracker - Fall 2019 \t---"
puts "---------------------------------------------------"
puts
classes.each do |key , value|
scraper = Scraper.new(classes[key])
seat = scraper.get_seats
seat.pop #Removes waitlist data
puts "Class: #{key} | Seats open: #{seat}"
puts "-----------------------------------------"
end
puts
puts
puts
puts "\t ...Checking Complete!... \t"
#contentHolder > div.pagebodydiv > table:nth-child(1) > tbody > tr:nth-child(2) > td > table > tbody > tr:nth-child(2) > td:nth-child(4)
end