Skip to content

Instantly share code, notes, and snippets.

@somapatrik
Last active September 19, 2020 06:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save somapatrik/a6a73f1cc90752f975f3d7b856864a25 to your computer and use it in GitHub Desktop.
Save somapatrik/a6a73f1cc90752f975f3d7b856864a25 to your computer and use it in GitHub Desktop.
Získání podrobnějších dat z API Ministerstva zdravotnictví (nakažení v okrese)
import requests, json
import datetime
yesterday = datetime.date.today() - datetime.timedelta(days=1)
url = "https://onemocneni-aktualne.mzcr.cz/api/v1/covid-19/osoby.json"
data = json.loads(requests.get(url).content)
filterdata = [x for x in data["data"] if (
(x["OkresKodBydliste"] == "CZ0422") and #laud kod
(x["DatumHlaseni"] == yesterday.strftime("%Y-%m-%d") )
)]
body="Dne " + yesterday.strftime("%d.%m.%Y") + " přibylo " + str(len(filterdata)) + " nakažených:\n"
for human in filterdata:
body += "Věk: " + human["Vek"] + " Pohlaví: " + human["Pohlavi"]
if (int(human['Import']) == 1):
body += " - Nakaženo v " + human['ImportZemeCsuKod'] + "\n"
else:
body += " \n"
print(body)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment