root/lang/perl/WWW-Mixi-Scraper/trunk/lib/WWW/Mixi/Scraper/Plugin/ResEcho.pm @ 18974

Revision 18974, 1.4 kB (checked in by charsbar, 5 years ago)

WWW-Mixi-Scraper: fixed pod and updated manifest and 0.19 -> CPAN

  • Property svn:eol-style set to native
Line 
1package WWW::Mixi::Scraper::Plugin::ResEcho;
2
3use strict;
4use warnings;
5use WWW::Mixi::Scraper::Plugin;
6use URI;
7
8validator {( page => 'is_number' )};
9
10sub scrape {
11  my ($self, $html) = @_;
12
13  my $scraper = scraper {
14    process 'div.archiveList>table>tr>td.comment',
15      'recents[]' => scraper {
16        process '//div[1]', id => 'HTML';
17        process '//div[2]', time => 'HTML';
18        process '//div[3]', name => 'HTML';
19        process '//div[4]', comment => 'HTML';
20    };
21    result 'recents';
22  };
23
24  my $stash = $self->post_process($scraper->scrape(\$html));
25  foreach my $echo ( @{ $stash } ) {
26      $echo->{link} = URI->new("http://mixi.jp/view_echo.pl?id=@{[$echo->{id}]}&post_time=@{[$echo->{time}]}");
27  }
28  return $stash;
29}
30
311;
32
33__END__
34
35=head1 NAME
36
37WWW::Mixi::Scraper::Plugin::ResEcho
38
39=head1 DESCRIPTION
40
41This would be equivalent to WWW::Mixi->parse_res_echo().
42(though the latter is not implemented yet as of writing this)
43
44=head1 METHOD
45
46=head2 scrape
47
48returns an array reference of
49
50  {
51    link    => 'http://mixi.jp/view_echo.pl?id=xxxx&post_time=xxxx',
52    id      => 'xxxx',
53    time    => 'yyyymmddhhmmss',
54    name    => 'username',
55    comment => 'comment',
56  }
57
58=head1 AUTHOR
59
60Kazuhiro Osawa
61
62=head1 COPYRIGHT AND LICENSE
63
64Copyright (C) 2008 by Kazuhiro Osawa.
65
66This program is free software; you can redistribute it and/or
67modify it under the same terms as Perl itself.
68
69=cut
Note: See TracBrowser for help on using the browser.