Saturday, January 11, 2020

How I buy tickets to sold out performances

Call it a talent or not, but quite often I still manage to get tickets to quite "hard to get to" events. It usually happens thanks to the discipline of being on time for the beginning of an online sale and by using multiple browsers simultaneously 😎.

Although recently I had to deal with something different. I've learned about an attractive event that had been already sold out for several weeks. For some time I've been thinking that I'm already late.

Contacting the ticket office didn't help much - they suggested it's only possible for new tickets to appear if only someone returns their tickets, and they are not necessarily going to appear on their website and rather be purchased in person at the box office on the day of the event.

Not an option for me. I'm glad I didn't believe them.

So I made an assistant!

A python app that checks their website for me once a minute and sends an SMS in case the sold out message changes to something else (hopefully, the cherished post about available tickets)! Very helpful!

Looking ahead, it took ~8k requests until "This performance is currently sold out" message changed to "Last chance to buy: only 2 tickets left". Exactly what I've been waiting for!

This is how the app works:

Once I've inspected what  <div> element stores the sold out message





used Beautiful Soup to scrape the web page and search for the content of that element, and SMTP protocol client to send SMS through Google G Suite (it's more like email to SMS gateway) when the content of the message changes. It's helpful to generate a dedicated google app password for the python app instead of using personal credentials.

At first, I thought that it's enough to send a push notification to my iPhone instead, using an app like Pushbullet, but its ios app appeared to be unavailable in Canada, and I continued with sending an SMS, it's easy enough.

The finished app was scheduled by crontab to check the website every minute.

The full code is available here: https://github.com/alled/scrape-tickets-website


May the tickets be with you!