Skip to content

Instantly share code, notes, and snippets.

@cuuupid
Created February 20, 2018 14:03
Show Gist options
  • Save cuuupid/5b121c02d114fc94bebd6b9a6f5ccf2a to your computer and use it in GitHub Desktop.
Save cuuupid/5b121c02d114fc94bebd6b9a6f5ccf2a to your computer and use it in GitHub Desktop.
Eventbrite Bot-smashing in Python with Selenium
import sys
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from time import sleep
# import star_me_daddy.utils
from console_logging.console import Console
console = Console()
from multiprocessing.dummy import Pool
tp = Pool(10)
_this = sys.modules[__name__]
_this.attempts = 0
def loop(whoami):
_this.attempts += 1
console.log("Started bot #%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")
# opts.add_argument('headless')
try:
browser = webdriver.Chrome(
chrome_options=opts, executable_path='./chromedriver')
browser.set_page_load_timeout(20)
console.info("Initialized Chrome Webdriver.")
except Exception as e:
console.error("Reached exception while initializing Chrome Webdriver.")
print(e)
return loop(whoami)
EVENT_URL = "https://www.eventbrite.co.uk/e/test-event-tickets-41726185143"
# page index to auto-open tickets modal
browser.get('%s#tickets' % EVENT_URL)
def run():
try:
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"
checkout_button.click()
console.success("Got to checkout.")
try:
sleep(3)
browser.find_element_by_id(
'first_name').send_keys(whoami['first'])
browser.find_element_by_id(
'last_name').send_keys(whoami['last'])
browser.find_element_by_id(
'email_address').send_keys(whoami['email'])
browser.find_element_by_id(
'confirm_email_address').send_keys(whoami['email'])
console.success("Filled out registration for %s %s" %
(whoami['first'], whoami['last']))
except Exception as e:
console.error(e)
except Exception as e:
console.error("Couldn't get tickets, trying again.")
browser.refresh()
run()
try:
run()
except Exception as e:
console.error(e)
browser.refresh()
return
people = [
{"first": "-", "last": "-", "email": "[email protected]"},
{"first": "-", "last": "-", "email": "[email protected]"},
{"first": "-", "last": "-", "email": "[email protected]"},
{"first": "-", "last": "-", "email": "[email protected]"},
{"first": "-", "last": "-", "email": "[email protected]"}
]
for person in people:
tp.apply_async(loop, args=[person])
while True:
1 + 1
# ^C to quit
console.success("Fin.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment