Skip to content

Instantly share code, notes, and snippets.

@nicolasleander
Last active November 14, 2015 14:55
Show Gist options
  • Save nicolasleander/f3a947d7999a81335eb0 to your computer and use it in GitHub Desktop.
Save nicolasleander/f3a947d7999a81335eb0 to your computer and use it in GitHub Desktop.
When you miss to book skydive in UAE
require 'open-uri'
require 'pry'
require 'nokogiri'
require 'logger'
require 'twilio-ruby'
# put your own credentials here
account_sid = 'xxxx'
auth_token = 'xxxxx'
# set up a client to talk to the Twilio REST API
@client = Twilio::REST::Client.new account_sid, auth_token
url = 'https://bookings.skydivedubai.ae/Slot/GetSlotsForDate'
logger = Logger.new(STDOUT)
logger.formatter = proc do |severity, time, progname, msg|
"#{time.utc.iso8601(3)} #{::Process.pid} #{progname} #{severity}: #{msg}\n"
end
loop do
page = Nokogiri::HTML(open(url))
available_dates = page.to_s.match('var availableDates = (?<yo>\S+)')[:yo]
available_dates_array = eval(available_dates)
unless available_dates_array.map { |x| x.split('-') }.select{ |x| x[0].to_i.between?(22, 27) && x[1] == '11'}.empty?
logger.info available_dates
logger.info 'GET IT!'
@send ||= @client.messages.create(
from: '+xxxxxxx',
to: '+xxxxxxx',
body: 'Book the Jump, maaaan'
) if @send.nil?
else
logger.info available_dates
end
sleep 30
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment