Skip to content

Instantly share code, notes, and snippets.

@wjlroe
Created April 8, 2010 17:28
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 wjlroe/360307 to your computer and use it in GitHub Desktop.
Save wjlroe/360307 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
require 'open-uri'
messages = {}
first_run = true
loop do
doc = Nokogiri::HTML(open('http://www.engadget.com/2010/04/08/live-from-apples-iphone-os-4-event/'))
doc.xpath('//div[@class="live_update"]').reverse.each do |live|
timestamp = live['timestamp']
if !timestamp.nil?
if !messages.has_key?(timestamp)
message = live.content.gsub(/'/,"").gsub(/"/,"")
messages[timestamp] = message
puts "Message: #{message}"
unless first_run
`say -v Vicki "#{message}"`
end
end
end
end
first_run = false
sleep 20
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment