Introduction of Wikipedia Module in Python
Wikipedia is a Python library that makes it easy to access and parse data from Wikipedia.Wikipedia is a multilingual online encyclopedia created and maintained as an open collaboration project by a community of volunteer editors using a wiki-based editing system.
In this article, we will see how to use Python%u2019s Wikipedia module to fetch a variety of information from the Wikipedia website.
In order to extract data from Wikipedia, we must first install the Python Wikipedia library, which wraps the official Wikipedia API. This can be done by entering the command below in your command prompt or terminal:
pip install wikipedia
Getting the summary of any title:
Summary of any tittle can be obtained by using
Syntax : wikipedia.summary(title, sentences)
Title of the topic
Optional argument: setting number of lines in result.
Return : Returns the summary in string format.
# importing the module
# finding result for the search
# sentences = 2 refers to numbers of line
result = wikipedia.summary("India", sentences = 2)
# printing the result