![]() |
![]()
| ![]() |
![]()
NAMEWWW::Scraper::ISBN - Retrieve information about books from online sources. SYNOPSISuse WWW::Scraper::ISBN; my $scraper = WWW::Scraper::ISBN->new(); $scraper->drivers("Driver1", "Driver2"); my @drivers = $scraper->available_drivers(); $scraper->drivers(@drivers); my $isbn = "123456789X"; my $record = $scraper->search($isbn); if($record->found) { print "Book ".$record->isbn." found by driver ".$record->found_in."\n"; my $book = $record->book; # do stuff with book hash print $book->{'title'}; print $book->{'author'}; # etc } else { print $record->error; } REQUIRESRequires the following modules be installed: DESCRIPTIONThe WWW::Scraper::ISBN class was built as a way to retrieve information on books from multiple sources easily. It utilizes at least one driver implemented as a subclass of WWW::Scraper::ISBN::Driver, each of which is designed to scrape from a single source. Because we found that different sources had different information available on different books, we designed a basic interface that could be implemented in whatever ways necessary to retrieve the desired information. METHODS
CODE EXAMPLEuse WWW::Scraper::ISBN; # instantiate the object my $scraper = WWW::Scraper::ISBN->new(); # load the drivers. requires that # WWW::Scraper::ISBN::LOC_Driver and # WWW::Scraper::ISBN::ISBNnu_Driver # be installed $scraper->drivers("LOC", "ISBNnu"); @isbns = [ "123456789X", "132457689X", "987654321X" ]; foreach my $num (@isbns) { $scraper->isbn($num); $scraper->search($scraper->isbn); if ($scraper->found) { my $b = $scraper->book; print "Title: ".$b->{'title'}."\n"; print "Author: ".$b->{'author'}."\n\n"; } else { print "Book: ".$scraper->isbn." not found.\n\n"; } } SEE ALSOAUTHOR2004-2013 Andy Schamp, E<lt>andy@schamp.netE<gt> 2013-2019 Barbie, E<lt>barbie@cpan.orgE<gt> COPYRIGHT AND LICENSECopyright 2004-2013 by Andy Schamp Copyright 2013-2019 by Barbie This distribution is free software; you can redistribute it and/or modify it under the Artistic Licence v2.
|