Created
January 28, 2015 08:42
-
-
Save akimicyu/4918af7b153142a12841 to your computer and use it in GitHub Desktop.
Nexus 6 checker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$ gem install httpclient
$ gem install clockwork
$ clockworkd -c nexus6_checker.rb start # 監視開始
$ clockworkd -c nexus6_checker.rb stop # 監視終了