Skip to content

Instantly share code, notes, and snippets.

@saipraveenkondapalli
Created May 24, 2020 10:34
Show Gist options
  • Save saipraveenkondapalli/389cd6c74846902fd3da0622c50d2171 to your computer and use it in GitHub Desktop.
Save saipraveenkondapalli/389cd6c74846902fd3da0622c50d2171 to your computer and use it in GitHub Desktop.
basic webscrapping for corona virus in india
import urllib.request
from bs4 import BeautifulSoup
url = urllib.request.urlopen('https://www.mohfw.gov.in/')
soup = BeautifulSoup(url, 'html.parser')
cases = soup.findAll('li', class_= 'bg-blue')
active_cases = cases[0].strong.text
cured = soup.findAll('li', class_= 'bg-green')
discharged= cured[0].strong.text
deceased = soup.findAll('li', class_ = 'bg-red')
dead = deceased[0].strong.text
print(f"\n Active cases = {active_cases} \n Cured/Discharged ={discharged} \n Deaths ={dead}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment