Skip to content

Instantly share code, notes, and snippets.

@antonioparisi
Last active November 8, 2016 13:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antonioparisi/de7e2e6362693c71e80d27700ca8c723 to your computer and use it in GitHub Desktop.
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.
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