2008/01/31


タレントスケジュールなんてサイトを見つけたので、さっそくスクレイピング。
ドキュメントに同じid属性が複数あるという、なんともダイナミックなHTMLにもめげず作り上げたのが以下 #!/usr/bin/perl

use encoding 'utf-8';
use strict;
use warnings;
use Encode qw(from_to);
use URI;
use URI::Escape qw(uri_escape_utf8);
use Web::Scraper;
use YAML;

if ($^O eq 'MSWin32') {
    binmode(STDERR, ':encoding(shift_jis)');
    Encode::from_to($ARGV[0], 'cp932', 'utf-8');
}
my $talent = shift || '小島よしお';

my $talent_schedule = scraper {
    process '//div[@class="find_bl"]/following-sibling::*[1]//td', day => 'TEXT';
    process '//div[@class="find_bl"]/following-sibling::*[1]//td/div',
        'schedule[]' => scraper {
            process 'div', media => sub { my $m = $_->attr('class'); $m =~ s/^icon_//g; $m };
            process '/div/a', url => '@href';
            process '/div/a', title => 'TEXT';
            process '/div/node()[1]', timespan => sub {
                my $s = $_->string_value;
                $s =~ s/ //;
                $s =~ s/(^|[^\d])(\d):(\d\d)/0$2:$3/g;
                my @span = split(/[^\d:]/, $s);
                \@span;
            };
        };
    result qw/day schedule/;
};
my $uri = URI->new('http://talent-schedule.jp/'.uri_escape_utf8($talent));
my $oppappi_schedule = $talent_schedule->scrape($uri);
warn Dump $oppappi_schedule;
ちょっと日付まわりで苦労してますが...

小島よしおって、結構番組出てますねぇ。

でもそんなの関係ry)
Posted at by




CodeReposに面白そうな物が入ってたので物色中。
どういうロジックでFriendを探しているのかは、まだ見てませんが...

こんなコードを実行すると... #!/usr/bin/perl

use strict;
use Net::Twitter::Friend::Finder::FromGoogle;

my $twitter = Net::Twitter::Friend::Finder::FromGoogle->new( {
        username => 'xxxxxxxxx',
        password => 'xxxxxxxxx' ,
        on_echo => 1,
        limit => 20 ,
        lang => 'ja' } );

$twitter->search;
$twitter->show;
こんな結果が返ります。 .----------------------------------------------.
| Net::Twitter::Friend::Finder::FromGoogle     |
'----------------------------------------------'
.---------+------------------------------------.
| Keyword | twitter                            |
'---------+------------------------------------'
.-----+----------------------+-----------------.
| #   | Twitter id           | Found count     |
'-----+----------------------+-----------------'
.-----+----------------------+-----------------.
| 1   | ikasam_a             | 1               |
| 2   | tsuda                | 1               |
| 3   | blog                 | 1               |
| 4   | help                 | 1               |
| 5   | tdtds                | 1               |
'-----+----------------------+-----------------'
なんだかwktk。

ところでFriend一覧で出てきたアカウント「help」って...

twitter-help
ちょwww
Posted at by




#!/usr/bin/perl
use strict;
use Perl6::Say;

undef &Perl6::Say::say;
sub my_say {
    my $this = shift;
    print @_;
    $this;
}
*Perl6::Say::say = \&my_say;

STDERR->say('フォォーー!!')->say('セイ')->say('セイ')->say('セイ');

こういうのは、おとなしく package IO::HG4;
use base qw(IO::Handle);

sub say {
    my $this = shift;
    print @_;
    $this;
}

IO::HG4->new->say('フォォーー!!')->say('セイ')->say('セイ')->say('セイ');
するのがいいと思った。
Posted at by