NAME
WWW::GoKGS::Scraper - Abstract base class for KGS scrapers
SYNOPSIS
use parent 'WWW::GoKGS::Scraper';
use URI;
use Web::Scraper;
sub _build_base_uri {
URI->new('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 two methods; _build_base_uri and _build_scraper. _build_base_uri must return a URI object which represents a resource on KGS. _build_scraper must return an Web::Scraper object which can scrape the resource. Both of them are called as a method on the object with no parameters.
ATTRIBUTES
- $URI = $scraper->base_uri
-
Returns a URI object which represents a resource on KGS. This attribute is read-only.
- $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
GETthe requested resource. Defaults to theLWP::UserAgentobject shared by Web::Scraper users ($Web::Scraper::UserAgent).
METHODS
- @filters = $scraper->get_filter( $key )
-
Returns all the filters associated with
$key. - $scraper->add_filter( $key => $filter )
- $scraper->add_filter( $k1 => $f1, $k2 => $f2, ... )
-
Pushes
$filteronto the filter stack specified by$key. You can also push multiple filters in oneadd_filtercall.$filtercan be either a filter class name or a subref. See Web::Scraper::Filter for details. - $filtered_value = $scraper->run_filter( $key, $value )
-
Executes all the filters associated with
$keyon$value. - $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
scrapemethod of an Web::Scraper object built by the_build_scrapermethod. - $scraper->query( $k1 => $v1, $k2 => $v2, ... )
-
Given key-value pairs of query parameters, constructs a URI object which consists of
base_uriand the query parameters, then pass theURIto thescrapemethod.
SEE ALSO
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.