Adding vaccination numbers
This commit is contained in:
parent
0aa1969191
commit
e32acdcdd9
@ -1,8 +1,10 @@
|
|||||||
|
from bs4 import BeautifulSoup
|
||||||
from pandas import read_csv
|
from pandas import read_csv
|
||||||
|
from urllib.parse import urlparse
|
||||||
|
import discord
|
||||||
|
import os
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import requests
|
import requests
|
||||||
import os
|
|
||||||
import discord
|
|
||||||
import string
|
import string
|
||||||
|
|
||||||
def get_csv():
|
def get_csv():
|
||||||
@ -59,10 +61,28 @@ def sum_numbers(location):
|
|||||||
embed.add_field(name=':rotating_light: Confirmed Cases :rotating_light:', value=confirmed, inline=False)
|
embed.add_field(name=':rotating_light: Confirmed Cases :rotating_light:', value=confirmed, inline=False)
|
||||||
embed.add_field(name=':hospital: Recovered Cases :hospital:', value=recovered, inline=False)
|
embed.add_field(name=':hospital: Recovered Cases :hospital:', value=recovered, inline=False)
|
||||||
embed.add_field(name=':skull_crossbones: Deaths :skull_crossbones:', value=deaths, inline=False)
|
embed.add_field(name=':skull_crossbones: Deaths :skull_crossbones:', value=deaths, inline=False)
|
||||||
embed.add_field(name='Source', value='https://github.com/CSSEGISandData/COVID-19')
|
embed.add_field(name=':sparkles: :syringe: NEW!: Percent vaccinated :syringe: :sparkles:', value=get_vaccination_data(location), inline=False)
|
||||||
|
embed.add_field(name='Source', value="https://github.com/CSSEGISandData/COVID-19\nVaccination numbers pulled from\nhttps://covidvaxcount.live")
|
||||||
|
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
def get_vaccination_data(location):
|
||||||
|
url = requests.get('https://covidvaxcount.live')
|
||||||
|
soup = BeautifulSoup(url.content, features="html.parser")
|
||||||
|
|
||||||
|
data = []
|
||||||
|
table = soup.find("div", {"class": 'table-responsive'})
|
||||||
|
table_body = table.find('tbody')
|
||||||
|
|
||||||
|
rows = table_body.find_all('tr')
|
||||||
|
for row in rows:
|
||||||
|
cols = row.find_all('td')
|
||||||
|
cols = [ele.text.strip() for ele in cols]
|
||||||
|
data.append([ele for ele in cols if ele]) # Get rid of empty values
|
||||||
|
|
||||||
|
state_name, num_vaccinated, population, percent_vaccinated = list(filter(lambda x: x[0] == location, data))[0]
|
||||||
|
return percent_vaccinated
|
||||||
|
|
||||||
def parse_message(message):
|
def parse_message(message):
|
||||||
try:
|
try:
|
||||||
state = string.capwords(' '.join(message.lstrip('!corona').split()))
|
state = string.capwords(' '.join(message.lstrip('!corona').split()))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user