Utilisateur:KelBot/kbll
<syntaxhighlight lang="perl">
- !/usr/bin/perl
use KelBot; use strict; use Getopt::Long;
my $pw;
my $page;
GetOptions('page=s' => \$page);
if ($page) {
kbget($page);
} else {
unless ($page) {
while ($page = <STDIN>) { $page =~ s/\n//; kbget($page); }
}
}
sub kbget {
my $page = shift; return unless ($page);
unless ($pw) {
$pw = KelBot->new('kbget');
} $page = `php -q ./urlencode.php "$page"`; my $text = $pw->get_text($page)."\n";
my %hash; while ( $text =~ /\[\[([^\]]*)\]\]/g ) {
my($link, $desc) = split(/\|/, $1); my($namespace, $name) = split(/:/, $link); if (length($namespace)>5) { $hash{ucfirst($link)} = 1; }
}
foreach (keys(%hash)) {
print $_."\n";
}
}