Skip to content

Instantly share code, notes, and snippets.

@DeviaVir
Created August 30, 2017 09:29
Show Gist options
  • Save DeviaVir/bac06f8beed5fc8ed9551ce480a91f21 to your computer and use it in GitHub Desktop.
Save DeviaVir/bac06f8beed5fc8ed9551ce480a91f21 to your computer and use it in GitHub Desktop.
ticketswap scraper, you simply run this by `python ticketswap-scrape.py` and wait for it to start beeping so you can order a ticket.
#!/usr/bin/python
import urllib
import time
import re
import os
# change this link to some other event or day
link = 'https://www.ticketswap.com/event/into-the-woods-festival-2017/friday/7bd7177f-5ca6-43bb-91e7-7bc2d467a5ab/71046'
beep = lambda x: os.system("echo -n '\a';sleep 0.2;" * x)
while True:
f = urllib.urlopen(link)
myfile = f.read()
matches = re.search('<div.*class="?.*counter-available.*"?.*>\n+.*<div.*class="?.*counter-value.*"?>.*</div>', myfile)
match = matches.group(0).split('\n')[1].strip()
match = match.replace('<div class="counter-value">', '').replace('</div>', '')
print match
if int(match) > 0:
# configure how many beeps you want to hear
beep(10)
# configure how often you want to check
time.sleep(5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment