Skip to content

Instantly share code, notes, and snippets.

@guilhermeslk
Created November 26, 2015 15:17
Show Gist options
  • Save guilhermeslk/c578946a4a66c76a6432 to your computer and use it in GitHub Desktop.
Save guilhermeslk/c578946a4a66c76a6432 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
require 'rubygems'
require 'open-uri'
require 'nokogiri'
SEARCH_URL = 'http://www.ofertaesperta.com/?ContentViewMode=Search&Search=ps4'
doc = Nokogiri::HTML(open(SEARCH_URL))
rows = doc.css('.oferta-title h4').select { |h4| h4.text =~ /Console/ }
prices = []
rows.each do |row|
div = row.ancestors('.top-note').first
prices << div.css('.preco').text().strip unless div.nil?
end
system "notify-send 'Menor Preço:' '#{prices.sort.first}'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment