Skip to main content

Wikipedia and MediaWiki API wrapper for Python

Project description

License GitHub release https://badge.fury.io/py/pymediawiki.svg Build Status Test Coverage Codacy Review Downloads

mediawiki is a python wrapper and parser for the MediaWiki API. The goal is to allow users to quickly and efficiently pull data from the MediaWiki site of their choice instead of worrying about dealing directly with the API. As such, it does not force the use of a particular MediaWiki site. It defaults to Wikipedia but other MediaWiki sites can also be used.

MediaWiki wraps the MediaWiki API so you can focus on leveraging your favorite MediaWiki site’s data, not getting it. Please check out the code on github!

Note: this library was designed for ease of use and simplicity. If you plan on doing serious scraping, automated requests, or editing, please look into Pywikipediabot which has a larger API, advanced rate limiting, and other features so we may be considerate of the MediaWiki infrastructure.

Installation

Pip Installation:

$ pip install pymediawiki

To install from source:

To install mediawiki, simply clone the repository on GitHub, then run from the folder:

$ python setup.py install

mediawiki supports python versions 2.7 and 3.4 - 3.7

Documentation

Documentation of the latest release is hosted on readthedocs.io

To build the documentation yourself run:

$ pip install sphinx
$ cd docs/
$ make html

Automated Tests

To run automated tests, one must simply run the following command from the downloaded folder:

$ python setup.py test

Quickstart

Import mediawiki and run a standard search against Wikipedia:

>>> from mediawiki import MediaWiki
>>> wikipedia = MediaWiki()
>>> wikipedia.search('washington')

Run more advanced searches:

>>> wikipedia.opensearch('washington')
>>> wikipedia.allpages('a')
>>> wikipedia.geosearch(title='washington, d.c.')
>>> wikipedia.geosearch(latitude='0.0', longitude='0.0')
>>> wikipedia.prefixsearch('arm')
>>> wikipedia.random(pages=10)

Pull a MediaWiki page and some of the page properties:

>>> p = wikipedia.page('Chess')
>>> p.title
>>> p.summary
>>> p.categories
>>> p.images
>>> p.links
>>> p.langlinks

See the Documentation for more examples!

Changelog

Please see the changelog for a list of all changes.

License

MIT licensed. See the LICENSE file for full details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pymediawiki-0.6.7.tar.gz (20.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pymediawiki-0.6.7-py2.py3-none-any.whl (23.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pymediawiki-0.6.7.tar.gz.

File metadata

  • Download URL: pymediawiki-0.6.7.tar.gz
  • Upload date:
  • Size: 20.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.25.0 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0

File hashes

Hashes for pymediawiki-0.6.7.tar.gz
Algorithm Hash digest
SHA256 659c84969351576c1a098c73f7df78e3b6612c5bf273b205da26660abb5c136a
MD5 ce35a407cdc7de791bca12046f0d18aa
BLAKE2b-256 d107782fecdf59b586f687cb5759edbcfb212858588a725195cbbf77f9ed45bb

See more details on using hashes here.

File details

Details for the file pymediawiki-0.6.7-py2.py3-none-any.whl.

File metadata

  • Download URL: pymediawiki-0.6.7-py2.py3-none-any.whl
  • Upload date:
  • Size: 23.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.25.0 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0

File hashes

Hashes for pymediawiki-0.6.7-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 6a5a8eef9b5e1d90b7d623f1e9ef7944b82aa5beaa8e607b9e7fa78ed8e8d039
MD5 e01bf238f5b94bf642416b4b3ed447d3
BLAKE2b-256 56c64fdb163f6d82e32f6702785ebbf409328c20814d63116032589ffa05bc47

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page