Skip to content

Instantly share code, notes, and snippets.

@ethagnawl
Forked from anonymous/buy-now-snes-classic.rb
Last active October 12, 2017 03:55
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 ethagnawl/8786f1c8e863128fbb2e6bc4a2c3f4ae to your computer and use it in GitHub Desktop.
Save ethagnawl/8786f1c8e863128fbb2e6bc4a2c3f4ae to your computer and use it in GitHub Desktop.
buy-now-snes-classic
require 'net/http'
require 'twilio-ruby'
require 'uri'
account_sid = 'SID'
auth_token = 'TOKEN'
@client = Twilio::REST::Client.new account_sid, auth_token
def notify!
@client.api.account.messages.create(
from: '+11111111111',
to: '+11111111111',
body: 'Quick! Buy now! https://www.thinkgeek.com/product/kmrn/'
)
end
def request
uri = URI.parse("https://www.thinkgeek.com/product/kmrn/")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(uri.request_uri)
response = http.request(request)
end
def orderable?(body)
body =~ /submitcart/
end
loop {
begin
if orderable?(request.body)
notify!
exit!
else
sleep 22
end
rescue StandardError => e
# keep on keepin' on
end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment