Automated 'Push' Restaurant menu

I love trying to automate the world, it just feels like magic some of the time! I also really enjoy information coming to me, instead of having to seek it. As we are still only in 2016, we have no world killing Artificial Intelligence (yet). So we have to start small, ease the first world problems! So I decided to make my workplaces' restaurant menu come to me!

I decided to write it in Ruby and use push notifications, rather than email or SMS. It uses a web automation framework called Selenium, which is available in many languages, including Javascript, Python, Java and obviously Ruby!

#!/usr/bin/env ruby
#Encoding: UTF-8
require 'nokogiri'
require 'net/http'
require 'open-uri' 
require 'rushover'
TOKEN="" # Fill this in, get from Pushover
USER="" # Fill this in, get from Pushover

page_url = ""
today ="%A")
items = []
page = Nokogiri::HTML(open(page_url, :proxy => nil))
page.xpath("//h2[contains(.,'#{today}')]/following-sibling::div[contains(@class, 'content')]/h4[contains(.,'Main')]/following-sibling::p[position() >= 0 and not(position() > 3)]").each do |node|
 items << node.text
items[0] = "\n\n " + items[0] { |word| "\n\n=#{word}" }

client =
resp = client.notify(USER, items.join("\n\n"), :sound => "classical", :device => "iPhone", :priority => 0, :title => "Today's Menu")
resp.ok? # => true

# Can check response from pushover if you want to verify it's sent
#puts resp.ok?

I have it set to run as a cron job on my work laptop, with an added bonus that it doesn’t run when I’m on holiday as the laptop is off. Here’s an example of the cron job:

# m h  dom mon dow   command
45 10 * * 1,2,3,4,5 $HOME/canteen-menu.rb

As you can see in the comments, the format for cron (on Ubuntu Linux) is: Minute, Hour, Day of Month, Month, Day of Week, Command.

So the time it runs is 10:45, any day of month, any month, only run Mon-Fri (1,2,3,4,5) and run our script command, easy!