Wikipedia Library For Python

@lee-rowe
Geek Culture
Published in
2 min readAug 5, 2021

--

Wikipedia is a Python library that makes it easy to access and parse data from Wikipedia. This extension allows you to 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. In this short blog post I will cover a few of the features that are included with this library:

Photo by Chris Karidis on Unsplash

To get started you will need to install the package, to install Wikipedia, simply run:

pip install wikipedia
  • search pages on Wikipedia — search(),
  • getting article summaries — summary,
  • changing the language of a page — set_lang().
  • getting full page contents, including images, links, and any other metadata of a Wikipedia page — page(),

Using the following commands above, I will demonstrate how to go about using each. As an example I will set the language to French for the output of the corresponding Wikipedia pages:

import wikipediawikipedia.set_lang('fr')print(wikipedia.search('Eiffel Tower'))

With an output that looks like…

['Tour Eiffel', 'Attentats du 11 septembre 2001', 'André The Giant', 'Erika Eiffel', 'Tour de…

--

--