Skip to content

Instantly share code, notes, and snippets.

@ryanvillarreal
Created February 10, 2020 18:22
Show Gist options
  • Save ryanvillarreal/6b4f72c0e280cde3a24dfffdd35b83aa to your computer and use it in GitHub Desktop.
Save ryanvillarreal/6b4f72c0e280cde3a24dfffdd35b83aa to your computer and use it in GitHub Desktop.
#!/usr/bin/python
# Add your OAUTH id and Event ID here
oauth = ''
event_id = ''
# load imports
from eventbrite import Eventbrite
import sys
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from time import sleep
# setting up multithreading for multi-user purchase support
from multiprocessing.dummy import Pool
tp = Pool(10)
_this = sys.modules[__name__]
_this.attempts = 0
# later add in the privacy.com API card generation - make sure to have a limit on how much you can spend
# setup billing information here
# get information from EB
print "Looks like we've got another mystery on our hands"
eventbrite = Eventbrite(oauth)
event = eventbrite.get_event(event_id)
url = event['url']
print "Lets go to the %s event gang!" % (event['name']['text'])
# going to use this to kill threads I think
def grab(culprit):
print "And I'd have gotten away with it, too, if it weren't for those meddling kids!"
# main loop
def loop(character):
_this.attempts += 1
# setup webdrivers and options - customize this as needed
print("Started mystery #%d" % _this.attempts)
opts = Options()
opts.add_argument('window-size=1200x600')
opts.add_argument(
"user-agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.0 Safari/537.36")
try:
print "Jinkies! We are starting the webdriver"
browser = webdriver.Chrome(chrome_options=opts, executable_path='./chromedriver')
browser.set_page_load_timeout(2)
print "Zoinks! It worked! Initialized Chrome Webdriver."
except Exception as e:
print "Jeepers! I can't find my glasses! Try fixing the chrome Webdriver"
alive = False # kill if errors out here
EVENT_URL = url
# page index to auto-open tickets modal
browser.get('%s#tickets' % EVENT_URL)
def run():
try:
print "Would you do it for a Scooby Snack?"
browser.find_element_by_tag_name('select').click()
browser.find_element_by_css_selector('option[value="1"]').click()
checkout_button = browser.find_element_by_css_selector('button[type="submit"]')
assert not checkout_button.get_attribute('disabled'), "Couldn't checkout"
try:
print "Time for a snack Scoob, lets take a break"
sleep(3)
except Exception as e:
print "Ruh Roh Raggy"
except Exception as e:
print "this is not right scoob, like we totally shouldn't be here"
browser.refresh()
run()
# the ability to add multiple people to register for the event
gang = [
{"first": "John", "last": "Smith", "email": "John.Smith@mailinator.com"},
{"first": "Jane", "last": "Doe", "email": "Jane.Doe@mailinator.com"}
]
for character in gang:
tp.apply_async(loop, args=[character])
alive = True
while alive:
1+1
if not alive:
sys.exit()
# cleanup
print "Scooby Dooby Doo!!!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment