Created
January 17, 2020 15:11
-
-
Save imakecodes/28513704af527a10d1a1c23e795a9fd2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pendulum | |
import requests | |
import os | |
timestamp = pendulum.now().format("YYYY-MM-DD-HH-mm") | |
filename = f"{timestamp}.json" | |
filepath = f"/home/mwilhelm/notebook/will/data/{filename}" | |
latest = f"/home/mwilhelm/notebook/will/data/latest.json" | |
base_url = "https://balneabilidade.ima.sc.gov.br/relatorio/mapa" | |
for i in range(5): | |
if os.path.isfile(filepath): | |
continue | |
r = requests.get(base_url) | |
if r.status_code == 200: | |
with open(filepath, "w") as f: | |
f.write(r.text) | |
with open(latest, "w") as f: | |
f.write(r.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment