# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# # Web Scrapping Corona Virus data into Ms Excel

# ## Requests

#Import library
import requests

#make request from webpage
url =' https://www.worldometers.info/coronavirus/country/india/'
result = requests.get(url)

# +
#result.text
# -

# ## Beautiful Soup

#Import library
import bs4

#create soup object
soup = bs4.BeautifulSoup(result.text, 'lxml')

# +
#soup
# -

# ## Extracting the data

# ### Find the div

#find-all method
cases = soup.find_all('div', class_ = 'maincounter-number')

cases

# ## Storing the data

#python list
data = []

#find the span and get data from it
for i in cases:
    span = i .find('span')
    data.append(span.string)

data

# ## Exporting the data

#Import library
import pandas as pd

#create a dataframe
df = pd.DataFrame({'CoronaData': data})

#naming the columns
df.index = ['TotalCases', 'Deaths', 'Recovered']

df

# +
#naming the file
# -

df.to_csv('Corona_Data.csv')



StarcoderdataJupyterScriptsDedupFiltered