SMS Travel alerts using Ruby, Twitter and BeautifulSoup
Ruby
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
helpers
README
dot-twitter-example
trains-example.yml
traintimes.rb

README

trainee
=======

SMS travel alerts using the traintimes.org.uk website, the incredible BeautifulSoup parser and Twitter DMs that you can choose to have sent as SMS messages.

All you need are a few ruby gems, an oauth token and secret from twitter.com/apps and a cron job to periodically run the script

INSTALL

- install the twitter and rubyful_soup gems
- setup the .twitter file with your twitter auth details, an example file (dot-twitter-example) is provided 
- setup the trains.yml file as required, an example file (trains-example.yml) is provided
- add an entry to your cron file to run the script as often as you'd like

CRON EXAMPLES

- Early each weekday morning:
30 6 * * 1-5 /usr/bin/ruby /home/suttree/src/twitter/trainee/traintimes.rb >> /dev/null 2>&1

- On the hour, every hour:
@hourly /usr/bin/ruby /home/suttree/src/twitter/trainee/traintimes.rb >> /dev/null 2>&1

TWITTER SETUP

- Go to http://twitter.com/apps and register an application that you will use to send DMs, and subsequently SMSs, to yourself.
- Then edit your twitter mobile settings at http://twitter.com/devices
- Run once, add something about pin entry in the .twitter file too
- Note that the first time you try running this, you'll need to do the OAuth PIN dance. Once you have the relelvant authorisation code, add that to your .twitter file (see dot-twitter-example) to see how it's done. From then on, the script should run without any user intervention.

TODO

- A better html parser to only send alerts when the train is delayed, rather than every time it is listed as happens now.