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::Driver(3) User Contributed Perl Documentation WWW::Scraper::ISBN::Driver(3)

WWW::Scraper::ISBN::Driver - Driver class for WWW::Scraper::ISBN module.

    use WWW::Scraper::ISBN::Driver;
    
    $driver = WWW::Scraper::ISBN::Driver->new();
    $driver->search($isbn);

    if ($driver->found) { ... }
    $driver->verbosity(1);
    
    my $book = $driver->book();
    print $book('title');
    print $driver->error;

Requires the following modules be installed:

    Carp

This is a base class, from which all site-specific drivers should inherit its members and methods. Driver subclasses named '$name' should be packaged as "WWW::Scraper::ISBN::$name_Driver", e.g. "WWW::Scraper::ISBN::LOC_Driver" for the LOC (Library of Congress) driver. Each driver need only implement the "search()" method, though they may have as many other methods as they need to get their job done. Only "search()" will be called by "WWW::Scraper::ISBN->search()".

It is important that the different drivers return at least a core set of information, though they may return additional information. The following self-explanatory fields should exist in "$driver->book":
author
title
isbn

In some cases, there may be no information for these fields, and so these may be set to the empty string. However, they must still be set in the hash!

Additional standard fields may be added in the future. 'pages', 'weight', 'height', 'depth and 'description' are common.

Due to the dynamic, ever-changing nature of the web, it is highly likely that the site from which many of these drivers glean their information will change. Hopefully, driver maintainers will keep drivers up to date, but they will all expire, and may behave unexpectedly. Keep this in mind if the driver continually returns weird results.

The following methods are provided by "WWW::Scraper::ISBN::Driver":
"new()"
    $drv = WWW::Scraper::ISBN::Driver->new()
    

Class constructor. Creates new driver object and returns a reference to it. Sets the following default values:

    found = 0;
    verbosity = 0;
    book = undef;
    error = '';
    
"found() or found($bool)"
    if ($drv->found) { # ... }
    $drv->found(1);
    

Accessor/Mutator method for handling the search status of this record. This is 0 by default, and should only be set true if search was deemed successful and "$driver->book" contains appropriate information.

"verbosity() or verbosity($level)"
    $driver->verbosity(3);
    if ($driver->verbosity == 2) { print 'blah blah blah'; }
    

Accessor/Mutator method for handling the verbosity level to be generated by this driver as it is going. This can be used to print useful information by the driver as it is running.

"book() or book($hashref)"
    my $book = $drv->book;
    print $book->{'title'}; 
    print $book->{'author'};
    $another_book = { 'title' => 'Some book title',
        'author' => "Author of some book"
    };
    $drv->book( $another_book );
    

Accessor/Mutator method for handling the book information retrieved by the driver. The driver should create an anonymous hash containing the standard fields. "WWW::Scraper::ISBN->search" sets the "WWW::Scraper::ISBN::Record->book()" field to this value.

"error() or error($error_string)"
    print $driver->error;
    $driver->error('Invalid ISBN number, or some similar error.');
    

Accessor/Mutator method for handling any errors which occur during the search. The search drivers may add errors to record fields, which may be useful in gleaning information about failed searches.

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

Searches for information on the given ISBN number. Each driver must define its own search routine, doing whatever is necessary to retrieve the desired information. If found, it should set "$driver->found" and "$driver->book" accordingly.

"handler() or handler($error_string)"
    $driver->handler('Invalid ISBN number, or some similar error.');
    

A generic handler method for handling errors. If given an error string, will store as per "$self->error($error_string)" and print on the standard output if verbosity is set. Returns "$self->found(0)".

"convert_to_ean13($isbn)"
Given a 10/13 character ISBN, this function will return the correct 13 digit ISBN, also known as EAN13.
"convert_to_isbn10($isbn)"
Given a 10/13 character ISBN, this function will return the correct 10 digit ISBN.
"is_valid($isbn)"
Given a 10/13 character ISBN, this function will return 1 if it considers it looks like a valid ISBN, otherwise returns 0.

The current list of known drivers can be installed via the following Bundle:

Bundle::WWW::Scraper::ISBN::Drivers

If you create a driver, please post a GitHub pull request or create an RT ticket against the Bundle distribution.

WWW::Scraper::ISBN

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.