NAME
WWW::GoKGS::Scraper::TournGames - Games of the KGS tournament
SYNOPSIS
use WWW::GoKGS::Scraper::TournGames;
my $tourn_games = WWW::GoKGS::Scraper::TournGames->new;
my $result = $tourn_games->query(
id => 762,
round => 1
);
# => {
# name => 'KGS Meijin Qualifier October 2012',
# round => 1,
# games => [
# {
# sgf_uri => 'http://files.gokgs.com/.../foo-bar.sgf',
# white => {
# name => 'foo',
# rank => '3d',
# },
# black => {
# name => 'bar',
# rank => '1d',
# },
# board_size => 19,
# start_time => '2012-10-27T16:05Z',
# result => 'W+Resign'
# },
# ...
# ],
# links => {
# entrants => [
# {
# sort_by => 'name',
# uri => '/tournEntrants.jsp?id=762&sort=n'
# },
# {
# sort_by => 'result',
# uri => '/tournEntrants.jsp?id=762&sort=s'
# }
# ],
# rounds => [
# {
# round => 1,
# start_time => '2012-10-27T16:05Z',
# end_time => '2012-10-27T18:35Z',
# uri => '/tournGames.jsp?id=762&round=1',
# },
# ...
# ]
# }
# }
DESCRIPTION
This class inherits from WWW::GoKGS::Scraper.
ATTRIBUTES
- $URI = $tuorn_games->base_uri
-
Defaults to
http://www.gokgs.com/tournGames.jsp
. This attribute is read-only. - $UserAgent = $tourn_games->user_agent
- $tourn_games->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 theLWP::UserAgent
object shared by Web::Scraper users ($Web::Scraper::UserAgent
). - $CodeRef = $tourn_games->date_filter
- $tourn_games->date_filter( sub { my $date = shift; ... } )
-
Can be used to get or set a date filter. Defaults to an anonymous subref which just returns the given argument (
sub { $_[0] }
). The callback is called with a date string such as2014-05-17T19:05Z
. The return value is used as the filtered value.use Time::Piece qw/gmtime/; $tourn_games->date_filter(sub { my $date = shift; # => "2014-05-17T19:05Z" gmtime->strptime( $date, '%Y-%m-%dT%H:%MZ' ); });
- $CodeRef = $tourn_games->result_filter
- $tourn_games->result_filter( sub { my $result = shift; ... } )
-
Can be used to get or set a game result filter. Defaults to an anonymous subref which just returns the given argument (
sub { $_[0] }
). The callback is called with a game result string such asB+Resign
. The return value is used as the filtered value.$tourn_games->result_filter(sub { my $result = shift; # I prefer "B+R" to "B+Resign", # while both of them are valid SGF-compatible format return 'B+R' if $result eq 'B+Resign'; ... $result; });
METHODS
- $HashRef = $tourn_games->scrape( URI->new(...) )
- $HashRef = $tourn_games->scrape( HTTP::Response->new(...) )
- $HashRef = $tourn_games->scrape( $html[, $base_uri] )
- $HashRef = $tourn_games->scrape( \$html[, $base_uri] )
- $HashRef = $tourn_games->query( id => $tourn_id, round => $round_nbr )
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.