Skip to main content

MediaWiki Tools

Coverage Status

A high level library containing set of tools for for filtering pages using the rich data available in MediaWikis such as categories and info boxes. Uses both web-scraping and API methods (where available and feasible) to gather information.

Goals

  • Generate useful data (and datasets) from a wiki.
  • To work on any MediaWiki (including fandom.com) with or without api.
  • Get arbitrary subsets of pages based on categories and template parameters (todo).
  • Be very robust to variations and inconsistencies in user input.
  • Be efficient.

Installation

Install it using pip.

pip install mediawiki-tools

Requires python >3.8 because I like the walrus operator.

Usage

Check out the basic usage guide and detailed API documentation.

Example

Question: Which countries in Asia use english as spoken Language?

Answer:

import mwtools

wiki = MediaWikiTools('en.wikipedia.org')

wiki.get_set(['Countries in Asia', 
              'English-speaking countries and territories'], 
             'and')
# ['Philippines', 'Pakistan', 'Bahrain', 'Singapore', 'Brunei', 'India']

Question: Which countries in Asia or Europe use english as spoken Language?

Answer:

wiki.get_set(['Countries in Asia', 'Countries in Europe',
              'English-speaking countries and territories'], 
             ['or','and'])
# ['Philippines',
#  'United Kingdom',
#  'Brunei',
#  'Malta',
#  'India',
#  'Pakistan',
#  'Scotland',
#  'Republic of Ireland',
#  'Singapore',
#  'Bahrain']

Question: Which of these countries are not island nations?

Answer:

wiki.get_set(['Countries in Asia', 'Countries in Europe',
              'English-speaking countries and territories',
              'Island countries'], 
             ['or', 'and', 'not'])
# ['Pakistan', 'India']

Metadata

Release files for MediaWiki-Tools 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for MediaWiki-Tools 0.1.1
File Size Uploaded Provenance Actions
MediaWiki-Tools-0.1.1.tar.gz 9.7 kB Without provenance Details for MediaWiki-Tools-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for MediaWiki-Tools 0.1.1
File Interpreter ABI Platform Actions
MediaWiki_Tools-0.1.1-py3-none-any.whl Python 3 none any Details for MediaWiki_Tools-0.1.1-py3-none-any.whl

Total release size: 18.9 kB

Release files / MediaWiki-Tools-0.1.1.tar.gz

Download URL MediaWiki-Tools-0.1.1.tar.gz
Size 9.7 kB
Tags Source
SHA-256 checksum
How to use checksums
9c7007e26ca797c45959cf1a7a0a110b4d4bb159f70b995fd88489a82c786174
BLAKE2b-256 checksum
How to use checksums
dfa8afcef432f503adac8acb326371f08a8b968200566391e86b4689e7f5f79c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

Release files / MediaWiki_Tools-0.1.1-py3-none-any.whl

Download URL MediaWiki_Tools-0.1.1-py3-none-any.whl
Size 9.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4abf205563656e4ddda0cf655ca5f9d8d272eb264a0fdb853fdd67e6b19c904c
BLAKE2b-256 checksum
How to use checksums
4a6d06ed7dc5e429363d39d78c1994da4d17c5e82faa8cf0a92eb9af27e4b563
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

Security for MediaWiki-Tools 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page