GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
WWW::Scraper::ISBN(3) User Contributed Perl Documentation WWW::Scraper::ISBN(3)

WWW::Scraper::ISBN - Retrieve information about books from online sources.

  use 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;
  }

Requires the following modules be installed:
WWW::Scraper::ISBN::Record
Carp

The 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.

"new()"
Class constructor. Returns a reference to an empty scraper object. No drivers by default
"available_drivers()"
Returns a list of installed drivers, which can be subsequently loaded via the drivers() method.
"drivers() or drivers($DRIVER1, $DRIVER2)"
  foreach my $driver ( $scraper->drivers() ) { ... }

  $scraper->drivers("DRIVER1", "DRIVER2");
    

Accessor/Mutator method which handles the drivers that this instance of the WWW::Scraper::ISBN class should utilize. The appropriate driver module must be installed (e.g. WWW::Scraper::ISBN::DRIVER1_Driver for "DRIVER1", etc.). The order of arguments determines the order in which the drivers will be searched.

When this method is called, it loads the specified drivers using 'require'.

Must be set before "search()" method is called.

"reset_drivers"
  $scraper->reset_drivers;
    

Sets the list of drivers to an empty array. Will disable search feature until a new driver is specified.

"search($isbn)"
  my $record = $scraper->search("123456789X");
    

Searches for information on the given ISBN number. It goes through the drivers in the order they are specified, stopping when the book is found or all drivers are exhausted. It returns a WWW::Scraper::ISBN::Record object, which will have its "found()" field set according to whether or not the search was successful.

If you have Business::ISBN installed, the method will attempt to validate the given isbn.

  use 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";
    }
  }

WWW::Scraper::ISBN::Driver
WWW::Scraper::ISBN::Record

  2004-2013 Andy Schamp, E<lt>andy@schamp.netE<gt>
  2013-2019 Barbie, E<lt>barbie@cpan.orgE<gt>

  Copyright 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.
2019-08-26 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.