Skip to content

Instantly share code, notes, and snippets.

@tomkersten
Created November 27, 2012 19: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 tomkersten/4156433 to your computer and use it in GitHub Desktop.
Save tomkersten/4156433 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# Do this:
# gem install httparty nokogiri
# Then run this file...
require 'httparty'
require 'nokogiri'
class HtmlParserIncluded < HTTParty::Parser
SupportedFormats.merge!('text/html' => :html)
def html
Nokogiri::HTML(body)
end
end
class Page
include HTTParty
parser HtmlParserIncluded
end
url = 'https://play.google.com/store/devices/details?id=nexus_4_16gb'
loop do
res = Page.get(url)
res.css('span.hardware-sold-out').each {|l|
if l.content != "Sold out"
puts url
`say "Nexus 4 is on sale"`
end
}
sleep 30
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment