16 lines
473 B
Python
16 lines
473 B
Python
from pathlib import Path
|
|
import requests as r
|
|
|
|
pattern = "http://www.dgis.salud.gob.mx/descargas/datosabiertos/nacimientos/sinac_{}.zip"
|
|
|
|
directory = Path("datasets")
|
|
_range = range(2008, 2023)
|
|
for value in _range:
|
|
target = pattern.format(value)
|
|
print(target)
|
|
response = r.get(target)
|
|
if response.status_code != 200:
|
|
print(response)
|
|
raise Exception("Error with download")
|
|
(directory / f"sinac-{value}.zip").write_bytes(response.content)
|