Skip to main content

Using MediaWiki's API, retrieve pages that belong to a given category

Project description

mw-category-members Build Status PyPI PyPI - Python Version

Using MediaWiki's API: retrieve pages that belong to a given category

Installation

pip install mw_category_members

Usage

import category_members

results = category_members.retrieve('Category:Presidents_of_the_United_States')
for r in results:
    print(r['name'], r['link'])

Arguments

def retrieve(cat_name, mw_instance='https://en.wikipedia.org', types=['page', 'subcat', 'file'], clean_subcat_names=False):
  • cat_name: Category name e.g. 'Category:Presidents_of_the_United_States'.
  • mw_instance: Which MediaWiki instance to use (the URL 'origin'). Defaults to 'https://en.wikipedia.org'.
  • types: Which types of pages to retrieve. Defaults to ['page', 'subcat', 'file'].
  • clean_subcat_names: If True, removes the e.g. 'Category:' prefix of the titles. Defaults to False.

Returns

Array of pages where a page is a dictionary of {'name': 'some name', 'link': 'some absolute link'}.

License

MIT.

Project details


Release history Release notifications

This version
History Node

0.1.0

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
mw_category_members-0.1.0-py3-none-any.whl (3.0 kB) Copy SHA256 hash SHA256 Wheel py3
mw_category_members-0.1.0.tar.gz (2.3 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page