Python - Details of CoronaVirus cases in various countries Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report In this article we will see how to make a script to get the details of corona virus cases i.e total cases, recovered cases and total deaths only by typing the name of the country. Modules required and Installation: Requests : Requests allows you to send HTTP/1.1 requests extremely easily. There’s no need to manually add query strings to your URLs. pip install requests Beautiful Soup: Beautiful Soup is a library that makes it easy to scrape information from web pages. It sits atop an HTML or XML parser, providing Pythonic idioms for iterating, searching, and modifying the parse tree. pip install beautifulsoup4 In order to make this script we have to do the following : 1. From the name of the country create URL 2. Scrape the data with the help of requests and Beautiful Soup 3. Convert that data into html code. 4. Find the required details and filter them. 5. Save the result in the dictionary. Below is the implementation - Python3 # importing libraries from bs4 import BeautifulSoup as BS import requests # method to get the info def get_info(country_name): # creating url using country name url = "https://www.worldometers.info/coronavirus/country/" + country_name + "/" # getting the request from url data = requests.get(url) # converting the text soup = BS(data.text, 'html.parser') # finding meta info for cases cases = soup.find_all("div", class_ = "maincounter-number") # getting total cases number total = cases[0].text # filtering it total = total[1 : len(total) - 2] # getting recovered cases number recovered = cases[2].text # filtering it recovered = recovered[1 : len(recovered) - 1] # getting death cases number deaths = cases[1].text # filtering it deaths = deaths[1 : len(deaths) - 1] # saving details in dictionary ans ={'Total Cases' : total, 'Recovered Cases' : recovered, 'Total Deaths' : deaths} # returning the dictionary return ans # setting country name country_name = "us" # calling the get_info method us = get_info(country_name) # printing the results for us print("Cases in United States") for i, j in us.items(): print(i + " : " + j) print("----------------------------") # setting country name to india country_name = "india" # calling the get_info method india = get_info(country_name) # printing the results for us print("Cases in India") for i, j in india.items(): print(i + " : " + j) Output : Cases in United States Total Cases : 654,343 Recovered Cases : 56,618 Total Deaths : 33,490 ---------------------------- Cases in India Total Cases : 12,759 Recovered Cases : 1,514 Total Deaths : 423 Comment More infoAdvertise with us Next Article Python - Get Confirmed, Recovered, Deaths cases of Corona around the globe R rakshitarora Follow Improve Article Tags : Python Python-requests Python-BS3 Web-scraping Python web-scraping-exercises +1 More Practice Tags : python Similar Reads Python - Get Confirmed, Recovered, Deaths cases of Corona around the globe In this article we will see how we can create a python script which tells about the cases of corona around the world i.e number of confirmed cases, number of cases in which patient has recovered and total deaths due to corona. Modules required and Installation: Requests : Requests allows you to send 2 min read Python - Get Confirmed, Recovered, Deaths cases of Corona around the globe In this article we will see how we can create a python script which tells about the cases of corona around the world i.e number of confirmed cases, number of cases in which patient has recovered and total deaths due to corona. Modules required and Installation: Requests : Requests allows you to send 2 min read Python IMDbPY â Getting the certificates of the series In this article we will see how we can get the certificates of series, certificates is basically certificated given to each series which tells about the nature of movie such as age-restricted certificate each certificate vary from country to country. In order to get this we have to do the following 2 min read How to get COVID 19 update using Covid module in Python? A new Python library which tells the COVID-19 related information (country-wise) and it show that how many cases of confirmed, active, deaths, recovered found in that particular Country. Requirement: You have python package named COVID and python >= 3.6 Installation: pip install covid Dependencie 3 min read Exploratory Data Analysis in Python | Set 1 This article provides a comprehensive guide to performing Exploratory Data Analysis (EDA) using Python focusing on the use of NumPy and Pandas for data manipulation and analysis.Step 1: Setting Up EnvironmentTo perform EDA in Python we need to import several libraries that provide powerful tools for 4 min read Exploratory Data Analysis in Python | Set 1 This article provides a comprehensive guide to performing Exploratory Data Analysis (EDA) using Python focusing on the use of NumPy and Pandas for data manipulation and analysis.Step 1: Setting Up EnvironmentTo perform EDA in Python we need to import several libraries that provide powerful tools for 4 min read Like