From a7d33038f4e616beaa23876f74c2195f2d006f2a Mon Sep 17 00:00:00 2001 From: Michael Howe Date: Sat, 24 May 2014 13:48:07 +0100 Subject: [PATCH] Upstream site has changed Make the ticket type/price code work again. --- split-route.pl | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/split-route.pl b/split-route.pl index 09035d7..753370f 100755 --- a/split-route.pl +++ b/split-route.pl @@ -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(); -- 2.39.5