User talk:Jpatokal/

From Wikitravel
Jump to: navigation, search 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 and run python2 before attempting to run the bot.

Known issue: The default Pywikipediabot 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.

Configuration[edit] 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

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 '$':

'''$NAME prefecture''' ($JAPANESE ''$NAME-ken'') is in [[Japan]].
* [[$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 is:

python2 -uusername -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  -uusername -n$i -e/bin/true

Questions and bug reports[edit]

This may be a stupid question but... Where do you enter the title for each new page or .dat file?

Very good question! The parameter NAME is automatically used as the title. Jpatokal 11:59, 19 March 2007 (EDT)


Sorry for being ignamoorse, but can Pywikipediabot be used on a Mac? -- Sapphire(Talk) • 01:55, 23 February 2008 (EST)

Yes. -- Colin 11:35, 23 February 2008 (EST)
BTW, I'm fairly sure that in its present form is not going to work with current versions of pywikipediabot, which is revised continually and regularly breaks old code. Sigh. Jpatokal 14:21, 23 February 2008 (EST)