From: Michael Howe Date: Sat, 24 May 2014 12:48:07 +0000 (+0100) Subject: Upstream site has changed X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=a7d33038f4e616beaa23876f74c2195f2d006f2a;p=pub%2Fmichael%2Fnational-rail-ticket-split.git Upstream site has changed Make the ticket type/price code work again. --- 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();