Extract Wikipedia Contents Using Python

0
643
Extract Wikipedia Contents Using Python

Extract Wikipedia Contents Using Python ( Python Tutorials : 4 )

Today we are going to use a new libray in python and see what it does. And the library is Wikipedia library.

Wikipedia is a library present in python which helps to access and parse data from wikipedia. We will check its basic usages and features as there are other amazing things we can do with it but all those as of now are for advanced users. So let’s get into it.

First install wikipedia using following command :

Now wikipedia library is ready to be imported. Basically, we can use this library to quickly check out few lines of information about any topic or anything that’s present in wikipedia by just writing few lines of script. It will just print the exact number of line you specify it to print, it won’t load the whole wikipedia information about that specific topic. For instance, if you want to see the first 2 lines(it means 2 fullstops) of information about Internet from wikipedia then it will only show you the first 2 lines. It won’t load the whole page for you. For example :

This above command will load first 2 lines about Internet from wikipedia.

That’s how simple it is and also it can be very useful sometimes. So what else you can do with it. We can assign a keyword to a variable and use it further to get more information about the keyword. Example :

This command will link the wikipedia page of internet into the variable ” int ” and now we can make use of ” int “ variable to do our further searches :

This will load everything that’s there about internet in wikipedia website. Similarly, we can also check the url of your keyword for quick link to it in your website or any other places, Example :

This will give the full url link of keyword internet in wikipedia. These are few things that you can do using wikipedia library in python.

That’s all in this article. Stay tuned for more cool stuffs.

LEAVE A REPLY