From Wikipedia, the free encyclopedia
Jump to navigation Jump to search

WLWP v0.1b[edit]

What it does[edit]

WLWP is a perl script to take your watchlist and turn it into a single RSS feed on your local computer, which can then be subscribed to with a feed reader. Generally, it should be run in a crontab. This is my crontab:

25,55 * * * * ~/bin/wlwp -u adodge -p PASSWORD -o ~/Sites/wprss.rss -q

Of course, I removed my password.

WLWP can also load a file with a list of articles and create a feed from that. This way, you can create different feeds for different topics, etc. Also, if you load from a file, WLWP doesn't need your login credentials every time it refreshes.

WLWP is currently a beta version, with a total of 45 minutes of work put into it. If you find any bugs or have a feature request, let me know.


You can contact me at my email address alexdodge at gmail dot com, or by posting to the talk page here. I also have a website at, where I will blog about new developments if I make them.


Just copy the code below into a file called "wlwp" and stick it somewhere in your PATH. Then you can set up your crontab and subscribe to the resulting feed.

You may have to install some perl modules to get this to work. It uses XML::FeedPP, URI::Escape, and Getopt::Std.

You can run "wlwp -h" for more information.


# Watchlist Wikipedia v0.1b
# Licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported
use strict;
use warnings;
use XML::FeedPP;
use URI::Escape;
use Getopt::Std;

my $version = "WLWP v0.1b (";

my %opts = (
	u => undef,  #-u <username>
	p => undef,  #-p <password>
	o => undef,  #-o <FILE> Select output file.
	t => undef,  #-t Don't list talk pages.
	s => undef,  #-s Output to STDOUT
	q => undef,  #-q Quiet mode
	d => undef,  #-d <FILE> Output subscription list to file. (Doesn't create RSS Feed.)
	l => undef,  #-l <FILE> Load subscription list from file.
	n => undef,  #-n <name> Name of feed
	h => undef,  #-h Show Help
	v => undef,
	n => undef,
getopts('n:u:p:o:tsqd:l:hv', \%opts);

if(defined $opts{'h'}){
	print <<_HELP_;
USAGE: wlwp [-u <USERNAME> -p <PASSWORD> [-d <FILE>]] [-l <FILE>] [-o <FILE>] [-n <NAME>] -tsqhv
wlwp creates an rss feed from a wikipedia watchlist or a file with a list of wikipedia articles.


Licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported

wlwp -u adodge -o wlwp.rss

USERNAME is the username of the user on wikipedia.  If this is not specified and -l is not set, the user will be prompted interactively.

PASSWORD is the password of the user on wikipedia.  If this is not specified and -l is not set, the user will be prompted interactively.

	-d <FILE>
If set, wlwp will dump the watchlist into FILE.  No rss feed will be created.

	-l <FILE>
If set, wlwp will load the watchlist from FILE.  If set, the username and password need not be provided.

	-o <FILE>
wlwp will output the rss feed to FILE.  If this is not specified and -s is not set, the user will be prompted interactively.

	-n <NAME>
NAME is the title of the RSS feed.  If this is not set, the title will be either the username or the watchlist filename.

Do not subscribe automatically to article talk pages.

If -o is not set, do not prompt the user interactively.  Instead, output to STDOUT.

Quiet mode.  Interactive prompts will still be printed.

Show this help and quit.

Print version information and quit.


if(defined $opts{'v'}){
	print $version."\n";

my ($username, $password, $outfile);

if(!defined $opts{'l'}){
		$username = $opts{'u'};
		print STDERR "Enter username: ";
		$username = <STDIN>;
		chomp $username;

		$password = $opts{'p'};
		print STDERR "Enter password: ";
		$password = <STDIN>;
		chomp $password;

my $title;

if(defined $opts{'n'}){
	$title = $opts{'n'};
}elsif(defined $opts{'l'}){
	$title = $opts{'l'};
	$title = $username;

if(!defined $opts{'d'}){
		$outfile = $opts{'o'};
			print STDERR "Enter file for output (blank for STDOUT): ";
			$outfile = <STDIN>;
			chomp $outfile;

my @list;

if(!defined $opts{'l'}){
	`curl -c ~/.wlwpcookies -A "$version" -d wpName=$username -d wpPassword=$password -d wpRemember=1 -d wpLoginattempt=Log+in "" 2> /dev/null`;
	my $data = `curl -b ~/.wlwpcookies -A "$version" "" 2> /dev/null`;
	die("Failure") if !($data =~ /<textarea id="titles" name="titles" rows="25" cols="80">(.*)<\/textarea>/s);
	@list = split("\n", $1);
	open (FD, '<', $opts{'l'});
		push @list, $_;
	close FD;

if(defined $opts{'d'}){
	open (FD, '+>', $opts{'d'});
	foreach my $item (@list){
		print FD $item."\n";

my @talkpages;

if(!defined $opts{'t'}){
	foreach my $o (@list){
		my $item = $o;
		if($item =~ /\w+:.*/){
			$item =~ s/(\w*):/$1_talk:/;
			$item = "Talk:$item";
		push(@talkpages, $item);

my $feed = XML::FeedPP::RSS->new();
$feed->title("WLWP - $title");

foreach my $item_orig (@list, @talkpages){
	print STDERR "$item_orig ... " if(!defined $opts{'q'});
	my $item = uri_escape($item_orig);
	my $tmpfeed = XML::FeedPP::RSS->new("$item&action=history&feed=rss");
	if( uri_unescape(($tmpfeed->get_item(0))->description()) =~ /<p><\/p>\n<p>Can\x27t load revision \d+<\/p>/){
		print STDERR "DNE" if(!defined $opts{'q'});
		print STDERR "ok" if(!defined $opts{'q'});
		my $i = 0;
		while(my $itemobj = $tmpfeed->get_item($i)){
			$itemobj->title($item_orig." - ".$itemobj->title());
			$i ++;
	print STDERR "\n" if(!defined $opts{'q'});

my $rss = $feed->to_string();

if(!defined $outfile || $outfile eq ""){
	print $rss;
	print FD $rss;
	close FD;