Free Software Directory:Participate/Using pywikibot

From Free Software Directory
Jump to: navigation, search

This page should be merged to Free Software Directory:Pywikibot.

You can also use pywikibot to work from the command line.


Create and activate an "isolated" virtual environment only for pywikibot (might be optional).

$ virtualenv --python=python3 v
$ source v/bin/activate

Clone the project, install and setup the bot.

$ git clone ""; cd core
$ pip install -r "requirements.txt"
$ python
Please insert URL to wiki:
Please insert a short name: fsd
$ python3 listpages -family:fsd -lang:en -debug -page:loomio -get

... Shows Loomio content.

Sample Python script to display the information from a given page

import os

import pywikibot
from pywikibot import config2

log = logging.getLogger(__name__)

class FSD(object):

    def __init__(self):
            'fsd', os.path.join(os.path.dirname(__file__),
                                'families/')) = pywikibot.Site(code="en", fam="fsd")

    def get(self, title):
        p = pywikibot.Page(pywikibot.Link(title,
        for (template, params) in p.templatesWithParams():
            if template.title() == 'Template:Entry':
                return params


Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the page “GNU Free Documentation License”.

The copyright and license notices on this page only apply to the text on this page. Any software or copyright-licenses or other similar notices described in this text has its own copyright notice and license, which can usually be found in the distribution or license text itself.