root/trunk/plagger/lib/Plagger/Plugin/CustomFeed/Frepa/FriendStatus.pm

Revision 1712 (checked in by nipotan, 2 years ago)

treated for site renewal of frepa

Line 
1 package Plagger::Plugin::CustomFeed::Frepa::FriendStatus;
2 use strict;
3 use warnings;
4 use HTML::Entities;
5 use Encode;
6
7 sub title { 'フレ友の最新ひとこと' }
8
9 sub start_url { 'http://www.frepa.livedoor.com/friend_status' }
10
11 sub get_list {
12     my ($self, $mech) = @_;
13
14     my @msgs = ();
15     my $res = $mech->get($self->start_url);
16     return @msgs unless $mech->success;
17
18     my $html = decode('euc-jp', $mech->content);
19     my $reg  = decode('utf-8', $self->_list_regexp());
20     while ($html =~ m|$reg|igs) {
21         my $time = "$1/$2/$3 $4:$5";
22         my ($subject, $link, $name) =
23             (decode_entities($6), decode_entities($7), decode_entities($8));
24
25         push(@msgs, +{
26             subject   => $subject,
27             name      => $name,
28             link      => $link,
29             user_link => $link,
30             time      => $time,
31         });
32     }
33     return @msgs;
34 }
35
36 sub _list_regexp {
37     return <<'RE';
38 <tr>
39 <th>(\d\d\d\d)\.(\d\d)\.(\d\d) (\d\d):(\d\d)</th>
40 <td>(.+?)\(<a href="([^"]+)">(.+?)</a>\)</td>
41 </tr>
42 RE
43 }
44
45 1;
46
Note: See TracBrowser for help on using the browser.