Skip to main content

Wikipedia and MediaWiki API wrapper for Python

Project description

License GitHub release Build Status Test Coverage Codacy Review PyPi Release 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 Pywikibot which has a larger API, advanced rate limiting, and other features so we may be considerate of the MediaWiki infrastructure. Pywikibot has also other extra features such as support for Wikibase (that runs Wikidata).

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 3.5 - 3.9

For python 2.7 support, install release 0.6.7

$ pip install pymediawiki==0.6.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.7.4.tar.gz (1.7 MB view details)

Uploaded Source

Built Distribution

pymediawiki-0.7.4-py3-none-any.whl (24.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pymediawiki-0.7.4.tar.gz
  • Upload date:
  • Size: 1.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.1

File hashes

Hashes for pymediawiki-0.7.4.tar.gz
Algorithm Hash digest
SHA256 fec43acf5d88e599708dde62dfc9107a4e322470d1c46eecd442af61d723e7c6
MD5 320a46809bb9e9e1b6a0abc21a82745f
BLAKE2b-256 4c0b1ac091235baec1fcc88849889b377158afbf52d77f8f10bfde6391919ed5

See more details on using hashes here.

File details

Details for the file pymediawiki-0.7.4-py3-none-any.whl.

File metadata

  • Download URL: pymediawiki-0.7.4-py3-none-any.whl
  • Upload date:
  • Size: 24.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.1

File hashes

Hashes for pymediawiki-0.7.4-py3-none-any.whl
Algorithm Hash digest
SHA256 23e95d8a6d3170414f6db4c8d1592c1458a7a2ad20dceb9d8541e5e19752fd95
MD5 7781059e280779635985278f3742952e
BLAKE2b-256 09833e9126b2cfa8082195bff319ccb822b784947f4a3ea58633295cda39217c

See more details on using hashes here.

Supported by

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