NAME

WWW::GoKGS::Scraper - Abstract base class for KGS scrapers

SYNOPSIS

use parent 'WWW::GoKGS::Scraper';
use WWW::GoKGS::Scraper::Declare;

sub base_uri { 'http://www.gokgs.com/...' }

sub __build_scraper {
    my $self = shift;

    scraper {
        ...
    };
}

DESCRIPTION

This module is an abstract base class for KGS scrapers. KGS scrapers must inherit from this class, and also implement the following methods:

base_uri

Must return a URI string which represents a resource on KGS. This method is called as a method on the class.

__build_scraper

Must return an Web::Scraper object which can scrape the resource. This method is called as a method on the object.

CLASS METHODS

$URI = $class->build_uri( $k1 => $v1, $k2 => $v2, ... )
$URI = $class->build_uri({ $k1 => $v1, $k2 => $v2, ... })
$URI = $class->build_uri([ $k1 => $v1, $k2 => $v2, ... ])

Given key-value pairs of query parameters, constructs a URI object which consists of base_uri and the paramters.

INSTANCE METHODS

$UserAgent = $scraper->user_agent
$scraper->user_agent( LWP::UserAgent->new(...) )

Can be used to get or set an LWP::UserAgent object which is used to GET the requested resource. Defaults to the LWP::UserAgent object shared by Web::Scraper users ($Web::Scraper::UserAgent).

$scraper->scrape( URI->new(...) )
$scraper->scrape( HTTP::Response->new(...) )
$scraper->scrape( $html[, $base_uri] )
$scraper->scrape( \$html[, $base_uri] )

Given arguments are passed to the scrape method of an Web::Scraper object built by the __build_scraper method.

$scraper->query( $k1 => $v1, $k2 => $v2, ... )

Given key-value pairs of query parameters, constructs a URI object which consists of base_uri and the parameters, then pass the URI to the scrape method.

INTERNAL METHODS

$class_name = $scraper->_tree_builder_class
$scraper->_tree_builder_class( 'HTTP::TreeBuilder::XPath' )

Can be used to get or set a class name which is used to build_tree. Defaults to HTML::TreeBuilder::XPath. You shouldn't modify this attribute unless you understand what you're doing.

use HTML::TreeBuilder::LibXML;
$scraper->_tree_builder_class( 'HTML::TreeBuilder::LibXML' );

SEE ALSO

WWW::GoKGS

AUTHOR

Ryo Anazawa (anazawa@cpan.org)

LICENSE

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.