Skip to content

Instantly share code, notes, and snippets.

@akimicyu
Created January 28, 2015 09:25
Show Gist options
  • Save akimicyu/b9f74be970b5c34e9987 to your computer and use it in GitHub Desktop.
Save akimicyu/b9f74be970b5c34e9987 to your computer and use it in GitHub Desktop.
Nexus 9 checker
#!/usr/local/bin/ruby
require 'rubygems'
require 'httpclient'
require 'clockwork'
include Clockwork
module Clockwork
def check
hc = HTTPClient.new
sites = [
"https://play.google.com/store/devices/details?id=nexus_9_black_32gb_lte",
"https://play.google.com/store/devices/details?id=nexus_9_black_32gb_wifi",
"https://play.google.com/store/devices/details?id=nexus_9_black_16gb_wifi",
"https://play.google.com/store/devices/details?id=nexus_9_white_32gb_wifi",
"https://play.google.com/store/devices/details?id=nexus_9_white_16gb_wifi",
]
begin
sites.each { |url|
html = hc.get_content(url)
`osascript -e 'display notification "Nexus9在庫あり! #{url}"'` unless (/現在在庫切れです。/ =~ html)
}
rescue => e
puts e.to_s
end
end
handler do |job|
self.send(job.to_sym)
end
every(1.minute, "check")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment