Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Python wrapper for the MediaWiki API to access and parse data from Wikipedia

License

NotificationsYou must be signed in to change notification settings

lehinevych/MediaWikiAPI

 
 

Repository files navigation

PyPI versionVersionPython packageGitHub IssuesLicenseDocs

MediaWikiAPI is a Python library that makes it easy to access and parsedata from Wikipedia.

Search Wikipedia, get article summaries, get data like links and imagesfrom a page, and more. Wikipedia wraps theMediaWiki API so you can focus on usingWikipedia data, not getting it.

>>>frommediawikiapiimportMediaWikiAPI>>>mediawikiapi=MediaWikiAPI()>>>print(mediawikiapi.summary("Wikipedia"))# Wikipedia (/ˌwɪkɨˈpiːdiə/ or /ˌwɪkiˈpiːdiə/ WIK-i-PEE-dee-ə) is a collaboratively edited, multilingual, free Internet encyclopedia supported by the non-profit Wikimedia Foundation...>>>mediawikiapi.search("Barack")# [u'Barak (given name)', u'Barack Obama', u'Barack (brandy)', u'Presidency of Barack Obama', u'Family of Barack Obama', u'First inauguration of Barack Obama', u'Barack Obama presidential campaign, 2008', u'Barack Obama, Sr.', u'Barack Obama citizenship conspiracy theories', u'Presidential transition of Barack Obama']>>>ny=mediawikiapi.page("New York (state)")>>>ny.title# u'New York (state)'>>>ny.url# u'http://en.wikipedia.org/wiki/New_York_(state)'>>>ny.content# u'New York is a state in the northeastern United States. New York was one of the original thir'...>>>ny.links[0]# u'1790 United States Census'>>>mediawikiapi.config.language="fr">>>mediawikiapi.summary("Facebook",sentences=1)# Facebook est un service de réseautage social en ligne sur Internet permettant d'y publier des informations (photographies, liens, textes, etc.) en contrôlant leur visibilité par différentes catégories de personnes.

Installation

To install MediaWikiAPI, simply run:

pip install mediawikiapi

MediaWikiAPI is compatible with Python 3.

Changelog

Changelog could be find in the documentation.

Documentation

The documentation is availablehere

To run tests, clone therepository on GitHub, then run:

poetry install poetry buildpoetry 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 sphinxcd docs/make html

To run formatter and mypy run:

poetry run mypy --strict .poetry run flake8 . --count --select=E9,F63,F7,F82 --show-source --statisticspoetry run black --diff --check .

To build the documentation run:

poetry run sphinx-build docs/source docs/build

License

MIT licensed. See theLICENSE file forfull details.

Credits

  • @goldsmith for making such a fantastic library to fork

About

Python wrapper for the MediaWiki API to access and parse data from Wikipedia

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python100.0%

[8]ページ先頭

©2009-2025 Movatter.jp