]> git.michaelhowe.org Git - pub/michael/national-rail-ticket-split.git/commitdiff
Upstream site has changed
authorMichael Howe <michael@michaelhowe.org>
Sat, 24 May 2014 12:48:07 +0000 (13:48 +0100)
committerMichael Howe <michael@michaelhowe.org>
Sat, 24 May 2014 12:48:07 +0000 (13:48 +0100)
Make the ticket type/price code work again.

split-route.pl

index 09035d7fb218f2b44176d923e4db4b7187523097..753370f99e578714ae4cb4abcbc228943f13f24a 100755 (executable)
@@ -202,8 +202,16 @@ sub get_stops {
         die "Error: first train returned by $url is not direct!\n";
     }
     my $details_url = $stop_li->look_down( '_tag', 'a', 'class', 'calling_link' )->attr('href');
-    my $ticket_type = $stop_li->look_down( '_tag', 'span', 'class', 'fare-type tooltip')->look_down('_tag', 'a')->as_text;
-    my $ticket_price = ( $stop_li->look_down( '_tag', 'label' ) )[0]->as_text;
+    my ( $ticket_type, $ticket_price );
+    if( my $fare_type_tooltip = $stop_li->look_down( '_tag', 'span', 'class', 'fare-type tooltip') ){
+        $ticket_type = $fare_type_tooltip->look_down('_tag', 'a')->as_text;
+        $ticket_price = ( $stop_li->look_down( '_tag', 'label' ) )[0]->as_text;
+    } else {
+        my $details_small = ( $stop_li->look_down('_tag', 'small') )[1];
+        my $ticket_and_price = $details_small->as_text();
+        ( $ticket_price, $ticket_type ) = $ticket_and_price =~ m{(\S+\d+\.\d{2})\s+(.*)};
+        debug( "Price: $ticket_price, type: $ticket_type" );
+    }
 
     $tree = $tree->delete();