Skip to content

Instantly share code, notes, and snippets.

@imakecodes
Created January 17, 2020 15:11
Show Gist options
  • Save imakecodes/28513704af527a10d1a1c23e795a9fd2 to your computer and use it in GitHub Desktop.
Save imakecodes/28513704af527a10d1a1c23e795a9fd2 to your computer and use it in GitHub Desktop.
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