Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/barrust/mediawiki
MediaWiki API wrapper in python http://pymediawiki.readthedocs.io/en/latest/
https://github.com/barrust/mediawiki
api-wrapper mediawiki parser parser-library python wikipedia
Last synced: 22 days ago
JSON representation
MediaWiki API wrapper in python http://pymediawiki.readthedocs.io/en/latest/
- Host: GitHub
- URL: https://github.com/barrust/mediawiki
- Owner: barrust
- License: mit
- Created: 2016-09-01T20:27:54.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2024-07-15T21:50:47.000Z (4 months ago)
- Last Synced: 2024-10-01T10:03:30.743Z (about 1 month ago)
- Topics: api-wrapper, mediawiki, parser, parser-library, python, wikipedia
- Language: Python
- Homepage:
- Size: 10.3 MB
- Stars: 180
- Watchers: 5
- Forks: 29
- Open Issues: 9
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
MediaWiki
=========.. image:: https://img.shields.io/badge/license-MIT-blue.svg
:target: https://opensource.org/licenses/MIT/
:alt: License
.. image:: https://img.shields.io/github/release/barrust/mediawiki.svg
:target: https://github.com/barrust/mediawiki/releases
:alt: GitHub release
.. image:: https://github.com/barrust/mediawiki/workflows/Python%20package/badge.svg
:target: https://github.com/barrust/mediawiki/actions?query=workflow%3A%22Python+package%22
:alt: Build Status
.. image:: https://codecov.io/gh/barrust/mediawiki/branch/master/graph/badge.svg?token=OdETiNgz9k
:target: https://codecov.io/gh/barrust/mediawiki
:alt: Test Coverage
.. image:: https://app.codacy.com/project/badge/Grade/34162198611f4aa0bde630d1dab72ce8
:target: https://www.codacy.com/gh/barrust/mediawiki/dashboard?utm_source=github.com&utm_medium=referral&utm_content=barrust/mediawiki&utm_campaign=Badge_Grade
:alt: Codacy Review
.. image:: https://badge.fury.io/py/pymediawiki.svg
:target: https://badge.fury.io/py/pymediawiki
:alt: PyPi Release
.. image:: http://pepy.tech/badge/pymediawiki
:target: https://pepy.tech/project/pymediawiki
:alt: 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.7 - 3.12
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 htmlAutomated 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:
.. code:: python
>>> from mediawiki import MediaWiki
>>> wikipedia = MediaWiki()
>>> wikipedia.search('washington')Run more advanced searches:
.. code:: python
>>> 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:
.. code:: python
>>> p = wikipedia.page('Chess')
>>> p.title
>>> p.summary
>>> p.categories
>>> p.images
>>> p.links
>>> p.langlinksSee 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.