![]() |
![]()
| ![]() |
![]()
NAMEWWW::Mixi::Scraper::Plugin - base class for plugins SYNOPSISpackage 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; DESCRIPTIONThis 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. METHODSnewcreates an object. html_or_textreturns the rendering mode of choice ('TEXT' or 'HTML'). parsegets content from a uri, scrapes, and returns an array (or a hash reference, etc) of data. build_uriused 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. get_contentgets content from the uri specified or from an optional html data. post_processdoes 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?). validatorprepares some simple validator for query parameters, though I'm not sure if this is really useful. AUTHORKenichi Ishigaki, <ishigaki at cpan.org> COPYRIGHT AND LICENSECopyright (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.
|