--- /dev/null
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+use WWW::Mechanize;
+use HTML::TreeBuilder;
+
+my $mech = WWW::Mechanize->new();
+
+my $query_site = "http://traintimes.org.uk";
+
+die "Usage: $0 <source> <dest> <date> <departure time>\n"
+ unless( scalar( @ARGV ) == 4 );
+
+my ( $src, $dest, $date, $depart ) = @ARGV;
+
+print "Finding routes from $src to $dest on $date at $depart\n";
+
+my $url = "${query_site}/${src}/${dest}/${depart}/${date}";
+print "Checking $url\n";
+
+my $stops = get_stops( $url );
+
+sub get_stops {
+ my ( $url ) = @_;
+
+ $mech->get( $url );
+
+ my $tree = HTML::TreeBuilder->new_from_content( $mech->content );
+
+ my $first_stop = $tree->look_down( '_tag', 'li', 'id', 'result0' );
+ my $details_url = $first_stop->look_down( '_tag', 'a', 'class', 'calling_link' )->attr('href');
+ my $ticket_type = $first_stop->look_down( '_tag', 'span', 'class', 'fare-type tooltip')->look_down('_tag', 'a')->as_text;
+ my $ticket_price = ( $first_stop->look_down( '_tag', 'label' ) )[0]->as_text;
+ print "Ticket type: $ticket_type\n";
+ print "Cost: $ticket_price\n";
+ print "stopping points URL: $details_url\n";
+}