post.py is a Pywikipediabot script for automated uploading of skeleton articles.
This script is intended for Pywikipediabot, which must be installed and configured first. Configure your account in user-config.py and run python2 login.py before attempting to run the bot.
Known issue: The default Pywikipediabot login.py can't recognize a successful login to Wikitravel, as Wikitravel returns three cookies, not four on successful login. Change the line that says
if len(L) == 4:
if len(L) > 1:
Note that Pywikipediabot's interface is not particularly stable and you will probably need to hand-hack the script a little to make it work with newer versions. Please update the script here after any changes.
post.py works by reading .dat files, injecting the content into a template and posting the merged document to a specified Wikitravel version.
The .dat file consists of key-value pairs like this:
NAME Akita LCASE akita JAPANESE 秋田 CAPITAL Akita
Keys should use alphabetic characters in the range A-Z only. The special key NAME is used as the title of the article to be created. Values can contain anything, including UTF-8 characters (which should be used for any non-ASCII characters) and continue until the end of the line. Generating the dat files is left up to you!
The template is simply a plain text file containing the skeleton Wiki article and variables flagged by '$':
[[Image:Japan_$LCASE_map_small.png|right]] '''$NAME prefecture''' ($JAPANESE ''$NAME-ken'') is in [[Japan]]. ==Understand== ==Cities== * [[$CAPITAL]] — The prefectural capital
Variable substitutions are performed against all variables listed in the dat file. Any variables not found in the dat file are ignored.
The command to actually run post.py is:
python2 post.py -uusername -ttemplate.wiki -nfile.date -e/bin/true
Once you have perfected the automated entry of a single file, you can use a shell loop to upload everything:
for i in dat-directory/*; do python2 post.py -uusername -ttemplate.wiki -n$i -e/bin/true done
Questions and bug reports
This may be a stupid question but... Where do you enter the title for each new page or .dat file?