Skip to content

Instantly share code, notes, and snippets.

@akimicyu
Created January 28, 2015 08:42
Show Gist options
  • Save akimicyu/4918af7b153142a12841 to your computer and use it in GitHub Desktop.
Save akimicyu/4918af7b153142a12841 to your computer and use it in GitHub Desktop.
Nexus 6 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_6_white_32gb",
"https://play.google.com/store/devices/details?id=nexus_6_white_64gb",
"https://play.google.com/store/devices/details?id=nexus_6_blue_32gb",
"https://play.google.com/store/devices/details?id=nexus_6_blue_64gb"
]
begin
sites.each { |url|
html = hc.get_content(url)
`osascript -e 'display notification "Nexus6在庫あり! #{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
@akimicyu
Copy link
Author

$ gem install httpclient
$ gem install clockwork
$ clockworkd -c nexus6_checker.rb start # 監視開始
$ clockworkd -c nexus6_checker.rb stop # 監視終了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment