line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::Mixi::Scraper::Plugin::ShowSchedule;
|
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1054
|
use strict;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
37
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
25
|
|
5
|
1
|
|
|
1
|
|
5
|
use WWW::Mixi::Scraper::Plugin;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
6
|
1
|
|
|
1
|
|
7
|
use utf8;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
my %Subjects = (
|
9
|
|
|
|
|
|
|
'isJoinedSchedule' => '予定',
|
10
|
|
|
|
|
|
|
'birthday' => '誕生日',
|
11
|
|
|
|
|
|
|
'isCommunityJoined' => '参加イベント',
|
12
|
|
|
|
|
|
|
'community' => 'イベント',
|
13
|
|
|
|
|
|
|
'isFriendSchedule' => 'マイミクの予定',
|
14
|
|
|
|
|
|
|
);
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
validator {(
|
17
|
|
|
|
|
|
|
year => 'number',
|
18
|
|
|
|
|
|
|
month => 'number',
|
19
|
|
|
|
|
|
|
pref_id => 'number',
|
20
|
|
|
|
|
|
|
)};
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub scrape {
|
23
|
0
|
|
|
0
|
1
|
|
my ($self, $html) = @_;
|
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
my %scraper;
|
26
|
|
|
|
|
|
|
$scraper{ym} = scraper {
|
27
|
0
|
|
|
0
|
|
|
process 'div.calendarBody>div.pageNavi>h3',
|
28
|
|
|
|
|
|
|
ym => 'TEXT';
|
29
|
0
|
|
|
|
|
|
result qw( ym );
|
30
|
0
|
|
|
|
|
|
};
|
31
|
0
|
|
|
|
|
|
my $ym = $scraper{ym}->scrape(\$html);
|
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
my ($year, $month) = $ym =~ /^(\d{4})\D+(\d{1,2})/;
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
$scraper{day} = scraper {
|
36
|
|
|
|
|
|
|
process 'span.date',
|
37
|
0
|
0
|
|
0
|
|
|
day => sub { $_->content and $_->content->[0] };
|
|
0
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
process 'ul>li',
|
39
|
0
|
|
|
|
|
|
'types[]' => sub { (split /\s/, $_->attr('class'))[-1] };
|
|
0
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
process 'ul>li>a',
|
41
|
|
|
|
|
|
|
'texts[]' => 'TEXT',
|
42
|
|
|
|
|
|
|
'links[]' => '@href';
|
43
|
0
|
|
|
|
|
|
result qw( day icons links texts types );
|
44
|
0
|
|
|
|
|
|
};
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
$scraper{list} = scraper {
|
47
|
0
|
|
|
0
|
|
|
process 'div.contents>table.calendarTable>tbody>tr>td',
|
48
|
|
|
|
|
|
|
'string[]' => $scraper{day};
|
49
|
0
|
|
|
|
|
|
result qw( string );
|
50
|
0
|
|
|
|
|
|
};
|
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
my @items;
|
53
|
0
|
|
|
|
|
|
foreach my $day ( @{ $scraper{list}->scrape(\$html) } ) {
|
|
0
|
|
|
|
|
|
|
54
|
0
|
0
|
|
|
|
|
next if $day->{day} =~ m{\d+/\d+};
|
55
|
0
|
|
|
|
|
|
my $date = sprintf '%04d/%02d/%02d', $year, $month, $day->{day};
|
56
|
|
|
|
|
|
|
|
57
|
0
|
0
|
|
|
|
|
my @texts = @{ $day->{texts} || [] };
|
|
0
|
|
|
|
|
|
|
58
|
0
|
0
|
|
|
|
|
my @links = @{ $day->{links} || [] };
|
|
0
|
|
|
|
|
|
|
59
|
0
|
0
|
|
|
|
|
my @types = @{ $day->{types} || [] };
|
|
0
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
0
|
0
|
0
|
|
|
|
next unless @texts && @links;
|
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
my $max = @texts;
|
64
|
0
|
|
|
|
|
|
for(my $ct = 0; $ct < $max; $ct++) {
|
65
|
0
|
0
|
|
|
|
|
next if $types[$ct] eq 'member';
|
66
|
0
|
0
|
|
|
|
|
my $icon = $types[$ct] eq 'birthday'
|
67
|
|
|
|
|
|
|
? 'http://img.mixi.jp/img/calendaricon2/i_bd.gif'
|
68
|
|
|
|
|
|
|
: 'http://img.mixi.jp/img/basic/icon/calendar_event001.gif';
|
69
|
|
|
|
|
|
|
|
70
|
0
|
|
0
|
|
|
|
push @items, {
|
71
|
|
|
|
|
|
|
subject => ($Subjects{$types[$ct]} || '不明'),
|
72
|
|
|
|
|
|
|
name => $texts[$ct],
|
73
|
|
|
|
|
|
|
link => $links[$ct],
|
74
|
|
|
|
|
|
|
icon => $icon,
|
75
|
|
|
|
|
|
|
time => $date,
|
76
|
|
|
|
|
|
|
};
|
77
|
|
|
|
|
|
|
}
|
78
|
|
|
|
|
|
|
}
|
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
return $self->post_process( \@items );
|
81
|
|
|
|
|
|
|
}
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1;
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
__END__
|