adrian is rad


sms alert for football (NFL) scores

Filed under: — adrian @ 11:35 pm

The other day, I was thinking it’d be cool to have sms alerts sent to my phone whenever the score changes in the Steelers game. I noticed that the NFL scores page has some peculiarities in their structure that would make it somewhat easy to pick out the scores.

There are people who you can pay to do this. (Or, I discovered today, there are sort of sketchy places that will do it for “free.”) But let’s say you don’t want to pay. And let’s say that you, like me:

  • have unlimited (or plenty of) sms’s
  • have a server or access to a server
  • are slightly obessive your team
  • love being a geek

So I wrote a perl script to do it (with some help from jesse and a lot of help from andyl). I’ve put it online here. Grab it if you want it. I ran it with a cron job which checked the score every two minutes during today’s Atlanta-New Orleans game:

[insert crappy picture of sms]

What you’ll need to do to make it work:

  1. download the file
  2. get WWW:Mechanize and HTML::Tree::Builder perl modules. if you’re running debian, you can type ‘apt-get install libwww-mechanize-perl’ and ‘apt-get install libhtml-tree-perl’ respectively.
  3. open Score:
    1. find ‘mail 0123456789\’ and replace it with your phone number and email gateway. (here are two lists of email gateways. So if you have sprint and your phone number is 987-654-3210 then your put ‘mail 9876543210\’. It’s important you \@ your @ sign or it won’t work.
    2. if you want the scores of a different team than the Steelers, find the two instances of ‘Pittsburgh’ in the file and replace them with your town’s name. (Check to check how they write it).
  4. save the file
  5. open your crontab file (in /etc/crontab) and add the following line:
    */2 9-21 * * 00 root perl /home/directorypath/Score >& /dev/null
    where /home/directorypath is whereever you’ve put the Score file. This will check the score every 2 minutes (*/2) between 9am and 9pm (9-21) on sundays (00). You can adjust these parameters if you’re on the east coast (adjust the times) or if your team is playing on a non-Sunday. 1 would be a Monday, etc.

It emails you the team names, their scores and the time (2nd Qtr, 2:54, for example).

It worked very nearly flawless during tonight’s game. I made one change so that when the game ends it’ll sms you the score and say it’s “Final” as well as smsing all the score changes. It does send one unnecessary sms when things are resetting the first time the cron job runs. You could probably figure out how to make it not do that.

I’m just putting this code out there. Use it if you like. I’m not really in a position to offer any warranties or support on it. I’m putting this out there under the Creative Commons Attribution-Noncommercial-Share Alike 2.5 License.

Pittsburgh friends, I can add you to my script if you want to get Steelers alerts too. Just let me know.

2 Responses to “sms alert for football (NFL) scores”

  1. Alex Says:

    Are you running this off your Mac, or another box?

  2. adrian Says:

    I’m running this off of my virtual server,

Leave a Reply

Spam protection by WP Captcha-Free

Powered by WordPress