Python 3 Web Scraping Script to Scrape Coronavirus COVID-19 Data From Worldometer API Using BeautifulSoup4 Library Full Project For Beginners

Python 3 Web Scraping Script to Scrape Coronavirus COVID-19 Data From Worldometer API Using BeautifulSoup4 Library Full Project For Beginners

 

Welcome folks today in this blog post we will be scraping covid-19 coronavirus data from worldometer api in python using beautifulsoup4 library. All the full source code of the application is shown below.

 

 

 

Get Started

 

 

 

In order to get started you need to make an app.py file and copy paste the following code

 

 

app.py

 

 

import requests
from bs4 import BeautifulSoup

url = 'https://www.worldometers.info/coronavirus/country/india/'

page = requests.get(url)
page = page.text
soup = BeautifulSoup(page, 'html.parser')
        
x1 = soup.findAll('h1')
x2 = soup.findAll("div", {"class": "maincounter-number"})
        
print('so, the total number of cases are')
for i,j in zip(x1[1:], x2):
            print(i.text, j.text)

 

 

 

Now if you execute the python script by typing the below command as shown below

 

 

python app.py

 

 

Leave a Reply