Skip to content

Instantly share code, notes, and snippets.

@webcracy
Created November 8, 2010 14:02
Show Gist options
  • Save webcracy/667714 to your computer and use it in GitHub Desktop.
Save webcracy/667714 to your computer and use it in GitHub Desktop.
Poll and Scrape TVI website for a given News Show and do growl notification
require 'rubygems'
require 'open-uri'
require 'cgi'
require 'hpricot'
require 'ruby-growl'
url = "http://www.tvi.iol.pt/frame_videos_tvi.html"
growl = Growl.new 'localhost', 'ruby-growl', ["ruby-growl Notification"]
loop do
doc = open(url) {|f| Hpricot(f)}
videos = (doc/"#accordionList2"/"div"/"div.title"/"div.titleCopy"/"span")
videos.each do |video|
if CGI.unescape(video.innerHTML).include? "Jornal da Uma - 22"
growl.notify "ruby-growl Notification", "TVI ALERT!", "Saiu a reportagem da Quodis"
puts CGI.unescape(video.innerHTML)
end
end
sleep 15
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment