Last active
August 29, 2015 14:06
-
-
Save rb2k/5f8a881a698ff20ba2ba to your computer and use it in GitHub Desktop.
apple iphone 6 search
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
require 'json' | |
require 'open-uri' | |
phones = { | |
'64 gb silver tmo' => 'MG5C2LL%2FA', | |
'64 gb gray tmo' => 'MG5A2LL%2FA' | |
} | |
zip_code = '02138' | |
loop do | |
system('clear') | |
phones.each_pair do |phone_type, code| | |
data = open("http://store.apple.com/us/retailStore/availabilitySearch?parts.0=#{code}&zip=#{zip_code}").read | |
JSON.parse(data)['body']['stores'].each do |store| | |
store['partsAvailability'].each do |item, availability| | |
available = !availability['pickupQuote'].include?('unavailable') | |
puts "****************" if available | |
puts "#{phone_type}: #{availability['pickupQuote']}" | |
puts "****************" if available | |
if available | |
system("say 'found an iphone'") | |
exit | |
end | |
end | |
end | |
end | |
puts "#{Time.now} ---------------------------" | |
sleep 600 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment