Wikipedia:WikiProject help desk/20050709 Dmcdevit.pl

Generates a list of all the articles from the rendered VfD page
 * 1) !/usr/bin/perl -w

use strict;

while (<>) { next unless /^\*?\[\[(.+?)\]\]/;

print $2, "\n"; }

Checks to see if a VfD page exists for a list of articles
 * 1) !/usr/bin/perl -w

use strict; use LWP::UserAgent; use URI::Escape;

my $pause = 1; #seconds between http fetches

$| = 1;

my $ua = LWP::UserAgent->new; $ua->timeout(10); $ua->env_proxy;

while(<>) { chomp;

if (check('Wikipedia:Votes_for_deletion/'. uri_escape($_))) { print $_, "\n"; }

sleep($pause); }

sub check { my $name = shift;
 * 1) returns 1 if a wikipedia article exists at that name, 0 otherwise

my $uri = 'http://en.wikipedia.org/wiki/'. $name; my $text;

while(1) { my $resp = $ua->get($uri);

if ($resp->is_success) { $text = $resp->content; last; } else { print STDERR "WARNING: $uri failed: "; print STDERR $resp->status_line, "\n"; }

sleep($pause); }

return 1 if index($text, 'Wikipedia does not have an article with this exact name.') == -1; return 0; }

Adds the links to the wikitext of VfD if it is in the list specified
 * 1) !/usr/bin/perl -w

use strict;

my %has_vfd;

my $file = shift(@ARGV) or die "must specify file name";

open(FILE, $file) or die "could not open $file: $!";

while() { chomp;

$has_vfd{$_} = 1; }

close(FILE);

while(<>) { chomp;

if (/^\*?\[\[(.+?)\]\]/ && defined($has_vfd{$2})) { print $_, " (VfD)"; } else { print; }

print "\n"; }