| WWW-Mixi-Scraper documentation | Contained in the WWW-Mixi-Scraper distribution. |
WWW::Mixi::Scraper::Plugin::ListMessage
This is almost equivalent to WWW::Mixi->parse_list_message().
returns an array reference of
{
subject => 'message title',
name => 'someone',
link => 'http://mixi.jp/view_message.pl?id=xxxx&box=xxx',
time => 'mm-dd',
envelope => 'http://mixi.jp/img/mail5.gif'
}
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.
| WWW-Mixi-Scraper documentation | Contained in the WWW-Mixi-Scraper distribution. |
package WWW::Mixi::Scraper::Plugin::ListMessage; use strict; use warnings; use WWW::Mixi::Scraper::Plugin; validator {qw( page is_number box is_anything )}; sub scrape { my ($self, $html) = @_; my %scraper; $scraper{messages} = scraper { process 'td.subject', string => 'TEXT'; process 'td.subject>a', link => '@href'; process 'td.status>img', envelope => '@src'; process 'td.date', date => 'TEXT'; process 'td.sender', sender => 'TEXT'; result qw( string envelope link date sender ); }; $scraper{list} = scraper { process 'div.messageListBody>table.tableBody>tr', 'messages[]' => $scraper{messages}; result qw( messages ); }; my $stash = $self->post_process( $scraper{list}->scrape(\$html) ); my @messages; for my $msg (@{ $stash }) { $msg->{sender} =~ s/^\s+//; $msg->{sender} =~ s/\s+$//; push @messages, { subject => $msg->{string}, name => $msg->{sender}, link => $msg->{link}, envelope => $msg->{envelope}, time => $msg->{date}, #??? }; } return $self->post_process( \@messages ); } 1; __END__