Seacolor Labs. このページをアンテナに追加 RSSフィード

2006-06-25

[] Subscription::VersionUpInfo 19:27  Subscription::VersionUpInfo - Seacolor Labs. を含むブックマーク はてなブックマーク -  Subscription::VersionUpInfo - Seacolor Labs.  Subscription::VersionUpInfo - Seacolor Labs. のブックマークコメント

できたんで公開。

package Plagger::Plugin::Subscription::VersionUpInfo;
use strict;
use base qw( Plagger::Plugin );

use Plagger::UserAgent;
use Plagger::Util;
use Encode;
use URI;

sub register {
    my($self, $context) = @_;
    $context->register_hook(
        $self,
        'subscription.load' => \&load,
    );
}

sub load {
    my($self, $context) = @_;

    my $url = URI->new("http://www2s.biglobe.ne.jp/~takao777/versionupinfo/");

    $context->log(info => "GET $url");

    my $agent = Plagger::UserAgent->new;
    my $res = $agent->fetch($url, $self);

    if ($res->http_response->is_error) {
        $context->log(error => "GET $url failed: " . $res->status_line);
        return;
    }

    my $content = Plagger::Util::decode_content($res);
    my $title   = Plagger::Util::extract_title($content);

    my $feed = Plagger::Feed->new;
    $feed->title($title);
    $feed->link($url);

    while ($content =~ m|<li><a href="(.*?)" target="_blank">(.*?)</a>(.*?)<!--.*-->(.*?)<(tt\|em)>(.*?)</\5>|g) {
        my($link, $title1, $title2, $body1, $body2) = ($1, $2, $3, $4, $6);
        my $title = $title1 . $title2;
        my $body = $body1 . $body2;

        my $entry = Plagger::Entry->new;
        $entry->title($title);
        $entry->link($link);
        $entry->body($body);

        $feed->add_entry($entry);
    }

    $context->update->add($feed);
}

1;

__END__

=head1 NAME

Plagger::Plugin::Subscription::VersionUpInfo - Create VersionUpInfo feed

=head1 SYNOPSIS

  - module: Subscription::VersionUpInfo

=head1 DESCRIPTION

This plugin creates a feed off of VersionUpInfo HTML pages.

=head1 AUTHOR

Kazushi Tominaga

=head1 SEE ALSO

L<Plagger>

=cut

Subscription::SoftAntennaもできたので、ついでに公開。

package Plagger::Plugin::Subscription::SoftAntenna;
use strict;
use base qw( Plagger::Plugin );

use Plagger::UserAgent;
use Plagger::Util;
use Encode;
use URI;
use URI::QueryParam;

sub register {
    my($self, $context) = @_;
    $context->register_hook(
        $self,
        'subscription.load' => \&load,
    );
}

sub load {
    my($self, $context) = @_;

    my $url = URI->new("http://www.softantenna.com/");

    $context->log(info => "GET $url");

    my $agent = Plagger::UserAgent->new;
    my $res = $agent->fetch($url, $self);

    if ($res->http_response->is_error) {
        $context->log(error => "GET $url failed: " . $res->status_line);
        return;
    }

    my $content = Plagger::Util::decode_content($res);
    my $title   = Plagger::Util::extract_title($content);

    my $feed = Plagger::Feed->new;
    $feed->title(decode('iso 2022-jp', $title));
    $feed->link($url);

    while ($content =~ m!<li class=saitem><strong><a href="(.*?)">(.*?)</a>.*</a>(.*?)</span><br>\n<span class=small>(.*?)</span>\n!g) {
        my($link, $title1, $title2, $body) = ($1, $2, $3, $4);
        my $title = $title1 . $title2;

        my $entry = Plagger::Entry->new;
        $entry->title(decode('iso 2022-jp', $title));
        $entry->link($link);
        $entry->body(decode('iso 2022-jp', $body));

        $feed->add_entry($entry);
    }

    $context->update->add($feed);
}

1;

__END__

=head1 NAME

Plagger::Plugin::CustomFeed::SoftAntenna - Create SoftAntenna feed

=head1 SYNOPSIS

  - module: Subscription::SoftAntenna

=head1 DESCRIPTION

This plugin creates a feed off of SoftAntenna HTML pages.

=head1 AUTHOR

Kazushi Tominaga

=head1 SEE ALSO

L<Plagger>

=cut