31 lines
1.2 KiB
Python
31 lines
1.2 KiB
Python
#!/usr/bin/python
|
|
|
|
import requests
|
|
from bs4 import BeautifulSoup
|
|
|
|
|
|
def get_current_data():
|
|
data_html = requests.get('https://www.worldometers.info/coronavirus/')
|
|
if(data_html.status_code == '200' or data_html.status_code == 200):
|
|
parsed_html = BeautifulSoup(data_html.text)
|
|
table = parsed_html.find('table', id='main_table_countries_today')
|
|
all_rows = table.findAll('tr')
|
|
for row in all_rows:
|
|
if(row and row.findAll('td') and row.find('a')):
|
|
all_cols = row.findAll('td')
|
|
if(row.find('a').text == 'USA'):
|
|
return f'''
|
|
{row.find('a').text}
|
|
Total Cases: {all_cols[1].text}
|
|
New Cases: {all_cols[2].text}
|
|
Total Deaths: {all_cols[3].text}
|
|
New Deaths: {all_cols[4].text}
|
|
Total Recovered: {all_cols[5].text}
|
|
Active Cases: {all_cols[6].text}
|
|
Serious/Critical: {all_cols[7].text}
|
|
Total Cases/1M Population: {all_cols[8].text}
|
|
'''
|
|
|
|
|
|
if(__name__ == '__main__'):
|
|
print(get_current_data())
|