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=':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)
if 'Not available' not in get_vaccination_data(location): # 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=':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") embed.add_field(name='Source', value="https://github.com/CSSEGISandData/COVID-19")
return embed return embed
def get_vaccination_data(location): # def get_vaccination_data(location):
url = requests.get('https://covidvaxcount.live') # url = requests.get('https://covidvaxcount.live')
soup = BeautifulSoup(url.content, features="html.parser") # soup = BeautifulSoup(url.content, features="html.parser")
data = [] # data = []
table = soup.find("div", {"class": 'table-responsive'}) # table = soup.find("div", {"class": 'table-responsive'})
table_body = table.find('tbody') # table_body = table.find('tbody')
rows = table_body.find_all('tr') # rows = table_body.find_all('tr')
for row in rows: # for row in rows:
cols = row.find_all('td') # cols = row.find_all('td')
cols = [ele.text.strip() for ele in cols] # cols = [ele.text.strip() for ele in cols]
data.append([ele for ele in cols if ele]) # Get rid of empty values # data.append([ele for ele in cols if ele]) # Get rid of empty values
try: # try:
state_name, num_vaccinated, population, percent_vaccinated = list(filter(lambda x: x[0] == location, data))[0] # state_name, num_vaccinated, population, percent_vaccinated = list(filter(lambda x: x[0] == location, data))[0]
except Exception: # except Exception:
return "Not available for %s" % location # return "Not available for %s" % location
return percent_vaccinated # return percent_vaccinated
def parse_message(message): def parse_message(message):
try: try: