User:Polbot/source/Use Polbot manual.p1
From Wikipedia, the free encyclopedia
< User:Polbot | source
use strict; use Q::Polbot; use Perlwikipedia; print "\nStarting polbot\n" ; my $pw=Perlwikipedia->new(); #$pw->{debug} = 1; $pw->{mech}->agent('Bot/WP/EN/Quadell/polbot'); print "Logging in\n"; my $login_status=$pw->login('bot name','bot password'); die "I can't log in." unless ($login_status eq 0); my @reps = (); print "Opening rep list\n"; my $replist = $pw->get_text('User:Polbot/fullreplist'); my @lines = split(/\n/, $replist); foreach my $line (@lines) { if ($line =~ m/^\*\s*\[\[(.*)\]\](.*)$/) { push @reps, "$1$2"; } } print scalar (@reps) . "\n"; print "Processing\n"; foreach my $line (@reps) { $line =~ m/^(.*)\|(.*)$/; my $name = $1; my $url = $2; print "$name: $url\n"; my $wiki_code = Polbot::bio2wiki($url); $pw->edit($name, $wiki_code, "Auto-generating new article based on $url"); $pw->edit("Talk:$name", "{{WPBiography|class=start|priority=low|needs-infobox=yes|politician-work-group=yes}}", "Auto-adding WPbiography template"); print "Article created."; print "\n"; sleep 15; } print "\nDone.\n";