Requires ruby... if you're on a mac you're good
sudo gem install nokogiri
(remove sudo if you know you don't need that)
run with ruby tots.rb
require 'nokogiri' | |
require 'open-uri' | |
def get_day(item_node) | |
item_node.parent.parent.parent.parent.parent.attributes['id'].value | |
end | |
def tot_days(nodes) | |
nodes.map {|node| get_day(node) } | |
end | |
menu_url = 'http://shopmason.gmu.edu/WeeklyMenu/SouthsideMenu/index.html' | |
html = open(menu_url) | |
# uncomment if you save the html to a local file called 'tots.html' for local testing | |
# save the file like so: `curl http://shopmason.gmu.edu/WeeklyMenu/SouthsideMenu/index.html > tots.html` | |
# html = File.read('tots.html') | |
doc = Nokogiri::HTML(html) | |
tot_names = ["French Fried Tater Tots", "Loaded Cheese Tots"] | |
tot_nodes = doc.css('div.menuitem span').select do |node| | |
tot_names.member? node.content | |
end | |
mmmmm = tot_days(tot_nodes) | |
if mmmmm.length > 0 | |
puts "TOTS ON:" | |
puts mmmmm | |
puts "HOLY SHIT! EAT TOTS, GET MONEY. https://tots.io (TM, patent pending)" | |
else | |
puts "NO TOTS!" | |
puts "QUIT SCHOOL" | |
end |