| 1 | package WWW::Mixi::Scraper::Plugin::ListMessage; | ||
| 2 | |||
| 3 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 1 | ▶ | use WWW::Mixi::Scraper::Plugin; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 1 | validator {qw( page is_number box is_anything )}; | |
| 8 | |||
| 9 | 0 | ▶ | sub scrape { |
|
Subroutine
scrape: not called CC=2 SCAR=17.9
Pod
documented
| |||
| 10 | 0 | my ($self, $html) = @_; | |
| 11 | |||
| 12 | 0 | my %scraper; | |
| 13 | 0 | ▶ | $scraper{messages} = scraper { |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 14 | 0 | process 'td.subject', | |
| 15 | string => 'TEXT'; | ||
| 16 | 0 | process 'td.subject>a', | |
| 17 | link => '@href'; | ||
| 18 | 0 | process 'td.status>img', | |
| 19 | envelope => '@src'; | ||
| 20 | 0 | process 'td.date', | |
| 21 | date => 'TEXT'; | ||
| 22 | 0 | process 'td.sender', | |
| 23 | sender => 'TEXT'; | ||
| 24 | 0 | result qw( string envelope link date sender ); | |
| 25 | 0 | }; | |
| 26 | |||
| 27 | 0 | ▶ | $scraper{list} = scraper { |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 28 | process 'div.messageListBody>table.tableBody>tr', | ||
| 29 | 0 | 'messages[]' => $scraper{messages}; | |
| 30 | 0 | result qw( messages ); | |
| 31 | 0 | }; | |
| 32 | |||
| 33 | 0 | my $stash = $self->post_process( $scraper{list}->scrape(\$html) ); | |
| 34 | |||
| 35 | 0 | my @messages; | |
| 36 | 0 | for my $msg (@{ $stash }) { | |
| 37 | 0 | $msg->{sender} =~ s/^\s+//; | |
| 38 | 0 | $msg->{sender} =~ s/\s+$//; | |
| 39 | push @messages, { | ||
| 40 | subject => $msg->{string}, | ||
| 41 | name => $msg->{sender}, | ||
| 42 | link => $msg->{link}, | ||
| 43 | envelope => $msg->{envelope}, | ||
| 44 | time => $msg->{date}, #??? | ||
| 45 | 0 | }; | |
| 46 | } | ||
| 47 | |||
| 48 | 0 | return $self->post_process( \@messages ); | |
| 49 | } | ||
| 50 | |||
| 51 | 1 | 1; | |
| 52 | |||
| 53 | __END__ | ||