WWW::Mixi::Scraper::Plugin - base class for plugins
package WWW::Mixi::Scraper::Plugin::<SamplePlugin> use strict; use warnings; use WWW::Mixi::Scraper::Plugin; validator {qw( id is_number )}; sub scrape { my ($self, $html) = @_; my %scraper; $scraper{...} = scraper { process '...', text => 'TEXT'; # always plain text process '...', text => 'HTML'; # always HTML process '...', depends => $self->html_or_text; # HTML or TEXT result qw( text depends ); }; return $self->post_process($scraper{...}->scrape(\$html)); return $arrayref; } 1;
This is a base class for WWW::Mixi::Scraper plugins. You don't need to use base qw( WWW::Mixi::Scraper::Plugin ); just use it. This exports Web::Scraper functions and several public and private methods/functions of its own.
use base qw( WWW::Mixi::Scraper::Plugin )
use
creates an object.
returns the rendering mode of choice ('TEXT' or 'HTML').
gets content from a uri, scrapes, and returns an array (or a hash reference, etc) of data.
used internally to build uri from query paramters (and optional hash). If you want to tweak the uri (e.g. to change authority from 'mixi.jp' to 'video.mixi.jp', etc), provide tweak_uri() in your plugin.
tweak_uri()
gets content from the uri specified or from an optional html data.
does some common tasks such as to make sure the result be an array reference, remove some temporary data to extract exact information, objectify link data (and maybe datetime data in the future?).
prepares some simple validator for query parameters, though I'm not sure if this is really useful.
Kenichi Ishigaki, <ishigaki at cpan.org>
Copyright (C) 2007 by Kenichi Ishigaki.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install WWW::Mixi::Scraper, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WWW::Mixi::Scraper
CPAN shell
perl -MCPAN -e shell install WWW::Mixi::Scraper
For more information on module installation, please visit the detailed CPAN module installation guide.