-
-
Save anonymous/d9cf3a523991a5f4e3752355973d7628 to your computer and use it in GitHub Desktop.
buy-now-snes-classic
This file contains hidden or 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 | |
response = request | |
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