|
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 | |
|---|
| 1 | package WWW::Mixi::Scraper::Plugin::ResEcho; |
|---|
| 2 | |
|---|
| 3 | use strict; |
|---|
| 4 | use warnings; |
|---|
| 5 | use WWW::Mixi::Scraper::Plugin; |
|---|
| 6 | use URI; |
|---|
| 7 | |
|---|
| 8 | validator {( page => 'is_number' )}; |
|---|
| 9 | |
|---|
| 10 | sub 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 | |
|---|
| 31 | 1; |
|---|
| 32 | |
|---|
| 33 | __END__ |
|---|
| 34 | |
|---|
| 35 | =head1 NAME |
|---|
| 36 | |
|---|
| 37 | WWW::Mixi::Scraper::Plugin::ResEcho |
|---|
| 38 | |
|---|
| 39 | =head1 DESCRIPTION |
|---|
| 40 | |
|---|
| 41 | This 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 | |
|---|
| 48 | returns 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 | |
|---|
| 60 | Kazuhiro Osawa |
|---|
| 61 | |
|---|
| 62 | =head1 COPYRIGHT AND LICENSE |
|---|
| 63 | |
|---|
| 64 | Copyright (C) 2008 by Kazuhiro Osawa. |
|---|
| 65 | |
|---|
| 66 | This program is free software; you can redistribute it and/or |
|---|
| 67 | modify it under the same terms as Perl itself. |
|---|
| 68 | |
|---|
| 69 | =cut |
|---|