Jump to content

Pywikipediabot: Difference between revisions

From IdeaWazaWiki
wikademia>Millosh
No edit summary
wikademia>Millosh
Line 27: Line 27:
=== Importing basic modules ===
=== Importing basic modules ===


Usually, [[User:Millosh|I am]] using this approach in calling basic PWB functions:
Usually, [[User:Millosh|I am]] using this approach in calling basic PWB functions (if you have some other approach, please add it here):


<source lang="python">
<source lang="python">

Revision as of 16:46, 23 December 2007

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 (if you have some other approach, please add it here):

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