MediaWikiAPI
MediaWikiAPI is a Python library that makes it easy to access and parse
data from Wikipedia.
Search Wikipedia, get article summaries, get data like links and images
from a page, and more. Wikipedia wraps the MediaWiki API so you can focus on using
Wikipedia data, not getting it.
>>> from mediawikiapi import MediaWikiAPI
>>> mediawikiapi = MediaWikiAPI()
>>> print(mediawikiapi.summary("Wikipedia"))
>>> mediawikiapi.search("Barack")
>>> ny = mediawikiapi.page("New York (state)")
>>> ny.title
>>> ny.url
>>> ny.content
>>> ny.links[0]
>>> mediawikiapi.config.language = "fr"
>>> mediawikiapi.summary("Facebook", sentences=1)
Installation
To install MediaWikiAPI, simply run:
pip install mediawikiapi
MediaWikiAPI is compatible with Python 3 and Python 2.7.
Changelog
Changelog could be find in the documentation.
Documentation
The documentation is available here
To run tests, clone the repository on GitHub, then run:
poetry install
poetry build
poetry run pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov=mediawikiapi
in the root project directory.
To build the documentation yourself, after installing requirements.txt, run:
pip install sphinx
cd docs/
make html
To run formatter and mypy run:
poetry run mypy --strict .
poetry run flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
poetry run black --diff --check .
License
MIT licensed. See the LICENSE file for
full details.
Credits
- @goldsmith for making such a fantastic library to fork