Skip to main content

Updated version of `wikipedia` package because original repo has been abandoned since 2014.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nlpia2_wikipedia-1.5.18.tar.gz (15.7 kB view details)

Uploaded Source

Built Distribution

nlpia2_wikipedia-1.5.18-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

Details for the file nlpia2_wikipedia-1.5.18.tar.gz.

File metadata

  • Download URL: nlpia2_wikipedia-1.5.18.tar.gz
  • Upload date:
  • Size: 15.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for nlpia2_wikipedia-1.5.18.tar.gz
Algorithm Hash digest
SHA256 ee33d72ebeae7a13ba810fa357fd901ea94a75ca9d328c07e33425b2db6bf748
MD5 3e0a454f84291f61ffe5219cec96c033
BLAKE2b-256 2edec25f4b3a58deac46c377bcad00486a84c12f59d55d9494458221c8743ebd

See more details on using hashes here.

File details

Details for the file nlpia2_wikipedia-1.5.18-py3-none-any.whl.

File metadata

File hashes

Hashes for nlpia2_wikipedia-1.5.18-py3-none-any.whl
Algorithm Hash digest
SHA256 0b723d258721666003391b813943bfcec666da5846e93907e9f53ad16379fd87
MD5 6e2b963fa2845e5ab241a94b4109dc46
BLAKE2b-256 772d37642950d54fd36f85816bc5a1319692f8c90e958b0788f40772bbdb2c96

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page