Last active
November 8, 2016 13:02
-
-
Save antonioparisi/de7e2e6362693c71e80d27700ca8c723 to your computer and use it in GitHub Desktop.
Now days find an iPhone 7 Plus is an hard mission. This is a simple script to check if it's available on the GiffGaff shop.
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 'watir' | |
require 'highline' | |
MEMORIES = ['32GB', '128GB', '256GB'] | |
COLORS = ['black', 'gold', 'jet black', 'rose gold', 'silver'] | |
cli = HighLine.new | |
memory = cli.choose do |menu| | |
menu.prompt = "Please choose the iPhone's memory:" | |
menu.choices(*MEMORIES) | |
menu.default = '128GB' | |
end | |
color = cli.choose do |menu| | |
menu.prompt = "Please choose the iPhone's color:" | |
menu.choices(*COLORS) | |
menu.default = 'black' | |
end.sub(/\s/, '-') | |
p '[*] Booting an hidden browser' | |
@browser = Watir::Browser.new(:phantomjs) | |
p '[+] Visiting GiffGaff web page...' | |
@browser.goto('https://www.giffgaff.com/mobile-phones/apple/apple-iphone-7-plus/phone-details') | |
p '[+] Checking availability for your settings...' | |
@browser.elements(id: 'phone-memory-apple-iphone-7-plus').first.li(text: memory).click | |
@browser.elements(id: 'phone-color-apple-iphone-7-plus').first.li(class: color).click | |
result = @browser.elements(class: 'phone-stock').first.elements.last.text | |
p "[+] Result: #{result}" | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment