-
-
Save ethagnawl/8786f1c8e863128fbb2e6bc4a2c3f4ae to your computer and use it in GitHub Desktop.
buy-now-snes-classic
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 '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