Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jfilter/mw-category-members
Using MediaWiki's API, retrieve pages that belong to a given category
https://github.com/jfilter/mw-category-members
mediawiki mediawiki-api python wikipedia wikipedia-api
Last synced: 3 months ago
JSON representation
Using MediaWiki's API, retrieve pages that belong to a given category
- Host: GitHub
- URL: https://github.com/jfilter/mw-category-members
- Owner: jfilter
- License: mit
- Created: 2018-09-09T10:22:32.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T07:44:11.000Z (about 2 years ago)
- Last Synced: 2024-10-01T10:04:01.693Z (4 months ago)
- Topics: mediawiki, mediawiki-api, python, wikipedia, wikipedia-api
- Language: Python
- Homepage: https://www.mediawiki.org/wiki/API:Categorymembers
- Size: 20.5 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mw-category-members [![Build Status](https://travis-ci.com/jfilter/mw-category-members.svg?branch=master)](https://travis-ci.com/jfilter/mw-category-members) [![PyPI](https://img.shields.io/pypi/v/mw-category-members.svg)](https://pypi.org/project/mw-category-members/) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/mw-category-members.svg)](https://pypi.org/project/mw-category-members/)
Using MediaWiki's API: retrieve pages that belong to a given category
## Installation
`pip install mw_category_members`
## Usage
```python
import category_membersresults = category_members.retrieve('Category:Presidents_of_the_United_States')
for r in results:
print(r['name'], r['link'])
```### Arguments
```python
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.