May 29, 2006
迷惑トラックバック対策:トラックバック…
こんにちは、楽天広場です。
迷惑トラックバック対策として、トラックバックURLの暗号化を行いました。
#!/usr/local/bin/perl
use strict;
use HTML::Entities;
use HTML::TokeParser;
use LWP::Simple;
my $url = 'http://plaza.rakuten.co.jp/hirobastaff/diary/200605290000/';
print rakuten_hiroba_trackback_auto_discovery($url), "\n";
sub rakuten_hiroba_trackback_auto_discovery {
my $url = shift;
my $content = get($url) or die "can't fetch $url";
my $p = HTML::TokeParser->new(\$content);
my $tb_url;
while (my $token = $p->get_tag('span')) {
if ($token->[1]->{class} eq 'jscrypt') {
my $crypted = decode_entities($token->[1]->{title});
$tb_url = join('', map { chr(ord($_) ^ 0x4) } split(//, $crypted));
last;
}
}
return $tb_url;
}