Skip to main content

Wikipedia

image

image

License

NLPiA2-Wikipedia Thin Python wrapper for Wikipedia API

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 wikipedia import wikipedia as wiki
>>> print(wiki.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...

>>> wiki.search("Barack")
['Barak (given name)', 'Barack Obama', ... 'Presidential transition of Barack Obama']
>>> titles = wiki.search("New York")
>>> page = wiki.page(titles[1])
>>> page.title
'New York (State)'
>>> page.url
'http://en.wikipedia.org/wiki/New_York_(state)'
>>> page.content
'New York, sometimes called New York State...'
>>> page.summary
'New York, sometimes called New York State...'
>>> page.links[0]
'10 Hudson Yards'

>>> wiki.set_lang("fr")
>>> wiki.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.

(or one of the other more advanced Python MediaWiki API wrappers), which has a larger API, rate limiting, and other features so we can be considerate of the MediaWiki infrastructure.

Installation

To install Wikipedia, simply run:

$ pip install nlpia2-wikipedia

Wikipedia is compatible with Python 2.6+ (2.7+ to run unittest discover) and Python 3.3+.

Documentation

Read the docs at https://wikipedia.readthedocs.org/en/latest/.

To run tests, clone the repository on GitHub, then run:

$ pip install -r requirements.txt
$ bash runtests  # will run tests for python and python3
$ python -m unittest discover tests/ '*test.py'  # manual style

in the root project directory.

To build the documentation yourself, after installing requirements.txt, run:

$ pip install sphinx
$ cd docs/
$ make html

License

MIT licensed. See the LICENSE file for full details.

Credits

Metadata

Release files for nlpia2_wikipedia 1.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nlpia2_wikipedia 1.6.1
File Size Uploaded
nlpia2_wikipedia-1.6.1.tar.gz 12.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nlpia2_wikipedia 1.6.1
File Interpreter ABI Platform
nlpia2_wikipedia-1.6.1-py3-none-any.whl Python 3 none any Details

Total release size: 27.4 kB

Release files / nlpia2_wikipedia-1.6.1.tar.gz

Download URL nlpia2_wikipedia-1.6.1.tar.gz
Size 12.6 kB
Tags Source
SHA-256 checksum
How to use checksums
7fa2b7b12463291790981591518dfbb6a97cdeeb7afa4a1ae3ad021a02d601f3
BLAKE2b-256 checksum
How to use checksums
96bef7554de6ef3cb2857dfba7ae7f85fb5b333245161147af09894abde08c0b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.8

Release files / nlpia2_wikipedia-1.6.1-py3-none-any.whl

Download URL nlpia2_wikipedia-1.6.1-py3-none-any.whl
Size 14.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
79a21201de032717bfe83c63f6fa33ec2a951981e21fe7363cecaec5879abe8f
BLAKE2b-256 checksum
How to use checksums
93dfe21f3010e3f1af5b68a07bc113510017766103f60a22739fa2d0961e9d5d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.8

Release history Release notifications | RSS feed

This release

1.6.1 This release

2 release files

1.6.0

2 release files

1.5.18

2 release files

1.5.17

2 release files

1.5.16

2 release files

1.5.15

2 release files

1.5.9

2 release files

1.5.8

2 release files

1.5.6

2 release files

1.5.4

2 release files

1.5.3

2 release files

1.5.2

2 release files

1.5.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page