Removing vaccination data as https://covidvaxcount.live is returning empty data

This commit is contained in:
ein 2021-06-29 13:18:00 -07:00
parent 77aba9045b
commit 9e1e3ce535

View File

@ -72,31 +72,31 @@ def sum_numbers(location):
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=':skull_crossbones: Deaths :skull_crossbones:', value=deaths, inline=False)
if 'Not available' not in get_vaccination_data(location):
embed.add_field(name=':sparkles: :syringe: Percent vaccinated :syringe: :sparkles:', value=get_vaccination_data(location) + "\nVaccination numbers pulled from\nhttps://covidvaxcount.live", inline=False)
# if 'Not available' not in get_vaccination_data(location):
# embed.add_field(name=':sparkles: :syringe: Percent vaccinated :syringe: :sparkles:', value=get_vaccination_data(location) + "\nVaccination numbers pulled from\nhttps://covidvaxcount.live", inline=False)
embed.add_field(name='Source', value="https://github.com/CSSEGISandData/COVID-19")
return embed
def get_vaccination_data(location):
url = requests.get('https://covidvaxcount.live')
soup = BeautifulSoup(url.content, features="html.parser")
# 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')
# 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
# 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
try:
state_name, num_vaccinated, population, percent_vaccinated = list(filter(lambda x: x[0] == location, data))[0]
except Exception:
return "Not available for %s" % location
return percent_vaccinated
# try:
# state_name, num_vaccinated, population, percent_vaccinated = list(filter(lambda x: x[0] == location, data))[0]
# except Exception:
# return "Not available for %s" % location
# return percent_vaccinated
def parse_message(message):
try: