Radiohead Ticket Notifier in Python

Written by Larry Kubin on March 4th, 2008 | Published in Programming

So Radiohead tickets went on pre-sale on a site called W.A.S.T.E. earlier this month. The problem with W.A.S.T.E. is that the site is based in the U.K. and they don’t tell you exactly when the tickets go on sale. So you just gotta keep refreshing the page. So many fans who wanted tickets decided to stay up all night to make sure they would get some since it was sure to sell out immediately (which it did).

At about 4am I started getting pretty bored and sleepy, so I decided to come up with a solution to this problem. The idea was to leave instant messenger on, and have a script that sends me an instant message when it detects a change in the website’s markup. The instant message noise would wake me up so that I could buy tickets. Below is the script I wrote. It uses the Python toc.py module, which can be downloaded here. Also, other people can instant message the bot, their screen name will be added to a list, and all people on the list will be notified. Pretty cool.

Note that I still ended up refreshing the page by hand just to be sure, since there was no real way to test that this thing was gonna work. It was a fun little experiment and I did get an instant message when the tickets went on sale. Neat huh? I now have a substantial number of Radiohead tickets that I will proceed to sell on eBay. Seriously, I’ve already sold 4 of them for a short term 50% gain, and I bet I will get more on the next batch. Don’t hate the player.

bot_screenname = "larry x2a"
bot_password   = "myaimpassword"
notify_list    = ['mrkubin42']
ticket_url     = 'http://tickets.waste.uk.com/Store/DisplayItems.html'
city_to_find   = 'Houston'
 
from toc import TocTalk, BotManager
 
import time
import urllib
 
class TickBot(TocTalk):
 
    def on_IM_IN(self,data):
        global notify_list
 
        screenname = data.split(":")[0]
 
        if not screenname in notify_list:
            notify_list.append(screenname)
 
        self.do_SEND_IM(screenname, '''Your screen name has been added to the notification list.''')
 
if __name__ == "__main__":
 
    bot = TickBot(bot_screenname, bot_password)
    bot._info = "IM me and I'll let you know when Radiohead tickets go on sale!"
 
    bm = BotManager()
    bm.addBot(bot,"myBot")
 
    times_checked = 0
 
    while 1:
        time.sleep(60)
 
        times_checked = times_checked + 1
        city_found = None
 
        page = urllib.urlopen(ticket_url)
 
        for line in page:
            if line.find(city_to_find) != -1:
                city_found = "Found It!"
 
        if city_found:
            for i in notify_list:
                bot.do_SEND_IM(i, '''Dude, Radiohead tickets are on sale! Go buy them!''')
        else:
            print "I checked " + str(times_checked) + " times and Radiohead tickets are still not on sale!"

Leave a Response