Intro
Hi there, as you read in this post we are going to do some data extracting from wikipedia in python. This project is very simple and fun to build and after reading this post please do comment down that what should I build next .
Modules required
-
wikipedia
: This module helps us to get data from wikipedia using python.
Installation
pip install wikipedia
Let's Code
First we will import the required module, so lets do it quickly
# importing the module
import wikipedia
Now we will ask the user to enter the subject he wants to search
search = input("What do you want to search ? \n")
Now we will use the input to search data from wikipedia
# finding result for the search
''' sentences = 2 refers to numbers of line the number may vary it is according to you '''
result = wikipedia.summary(search, sentences = 2)
Now we will finally print the result
# printing the result
print(result)
And with that done we have successfully completed another project.
That's it for today stay safe and do take very good care of yourselves and VERY HAPPY NEW YEAR !
Top comments (3)
Although getting from a Wikipedia API is fine, but not all information found on websites would provide you with an API. An API is a source of info scraped from a website or retrieved from a database such as SQL.
An example Databases include :
So if a website has no API, you can still get information from it!
Using BS4 or Beautiful Soup 4 A python module to web scrape information from a website where you can do requests. It's a really useful module to add to your skillset!
You can use Web Scraping!
Yeah thanks for sharing, I know that but this script is for using just the Wikipedia module.
ok then 😀