Web Scraping Websites Using Python

When it comes to Programming languages it is obvious that it is the most powerful programming language because there is every work you can do with Python there is a library present for every task for example for scraping we will use BeautifulSoup or bs4 it is very popular library for scraping data from websites... So lets start..

 INSTALLING LIBRARY:

First you need to install Python in your particular OS mine is WIndows so after installing Python you need to open cmd and run command for installing library we need two library 1. bs4 2. requests

bs4 library to scrape data and requests library to make request to http..

Installing BS4 :

run this command : pip install bs4


Installing Requests:

run this command : pip install requests


Now choose which website you want to scrape we will scrape https://www.mohfw.gov.in/ to scrape covid data from this government website.. So we will scrape Active Cases, Deaths etc


first import libraries:


You need to first inpect the class objects from website and which tags to scrape data.. Here as you can see we find "ul " tag with "li"  and we put the data inside a function and looped through. dont forget to use .get_text() function to get text in the console and print it. We put the data in tkinter GUI 


Post a Comment

0 Comments