Jump to content

Pywikipediabot

From IdeaWazaWiki
Revision as of 16:46, 23 December 2007 by wikademia>Millosh

Pywikipediabot (PWB) is the "Python Wikipediabot Framework is a set of bot scripts to do things on Wikipedia or other wikis using MediaWiki. It has been written by several people using the language Python. On this page, we give the general information for people who want to use the bot software."

Needed skills

This course assumes that you know/have:

  • Installed Python on your operating system
  • Using necessary tools
  • Python basics
  • Introduction into Wikimedia projects

Installing pywikipediabot framework

Documentation on Pywikipediabot page is very good. Use it for initial instructions.

Some general basics

Your bot should assume that it is multilingual. Because of that, use UTF-8 (or some better character set) and declare it at the beginning of your Python script:

<source lang="python">

  1. !/usr/bin/python
  2. -*- coding: utf-8 -*-

</source>

Pywikipediabot basics

Importing basic modules

Usually, I am using this approach in calling basic PWB functions:

<source lang="python"> mydir = "./" pwbdir = mydir + "pywikipedia/" import sys sys.path.append(pwbdir) from wikipedia import * </source>