Monitoring a Twitter feed and making your phone explode for DerbyCon

It might be useful to monitor a Twitter feed for a specific keyword.  For example your favorite band is selling tickets or some other time sensitive event.  I would like to attend Derbycon this year, but I missed the sale date.  It is however rumored that the guys at DerbyCon are holding onto a bunch of tickets and plan to release them on occasion and will likely advertise this fact on Twitter.

There might also be private sellers who are now unable to attend the convention.

I don’t have a tremendous use for Twitter at the moment, so I don’t plan on checking my feed on a regular basis.  But I do want to be alerted if the word “ticket” shows up in Derbycon’s feed; and I want to be alerted hard and fast.  To achieve this, I made a very simple Python script.   Yes, I know there is many companies which offer similar services, however they want money and are more geared towards those who need data mining services.

To get started, you’ll need a Twitter account.  You may even want to create a secondary account for this purpose.  Next you’ll need to get an API key and create an application.  (there’s a ton of sites that explain this a whole lot better then I will).

You need to know when your chosen keyword shows up in your target’s feed.  To do this, I’m using a package call “tweepy”  (pip install tweepy).   Then you need to create a listener which waits for tweets to be pushed your way for parsing.  Your code might look something like this:

 

Next, you need to get yourself notified.  Please remember how annoying this could become!  You’ll probably want to put in some logic so that you don’t get notified more then once per hour for example.  I configured Twilio to handle the notifications, it can send SMS messages and call my phone if “ticket” show up in the DerbyCon feed.

Finally, you need to make your script run, to do this I dropped it onto a server and ran it as a scheduled task.

 

 

 

 

 

 

 

 

Update:  It worked!  Got a SMS and called within a few seconds of someone posting @Derbycon with a single ticket for sale. I messaged to seller within 32 seconds of his tweet.  I snagged the ticket up.

Leave a Reply

Your email address will not be published. Required fields are marked *