Book Searching with Perl Under The Hood 23 of 29 : [PREV] [NEXT]

Get The Link

      # The Search Results page
      my $template = <<END;
<!-- BOOK COLLECTION -->[% ... %]<a href="[% book %]" target="_self">[% ... %]
END

      my $extract = Template::Extract->new;
      my $data = $extract->extract($template, $mechanize->content());

      unless(defined $data) {
              print "Error extracting data from ORA result page.\n" if $self->verbosity;
              $self->error("Could not extract data from ORA result page.\n");
              $self->found(0);
              return 0;
      }

      my $book = $data->{book};
  • simple template, which extracts the book link
  • use Template::Extact to do the work for us.
  • report problems if we couldn't grab the book link
  • If okay, store the book link

© 2004 Barbie barbie@missbarbell.co.uk Home http://birmingham.pm.org/