Commit b7da7eaf authored by Eric Duminil's avatar Eric Duminil
Browse files

Trying to download zip files for Berlin

parent 7e39bcda
import xml.etree.ElementTree as ET
from datetime import datetime
from pathlib import Path
from citygml_download import TMP_DIR, Bundesland, download_all_files, download_file from citygml_download import TMP_DIR, Bundesland, download_all_files, download_file
from zipfile_download import ZipFile from zipfile_download import ZipFile
...@@ -7,3 +11,31 @@ BERLIN = Bundesland( ...@@ -7,3 +11,31 @@ BERLIN = Bundesland(
info="https://gdi.berlin.de/geonetwork/srv/ger/catalog.search#/metadata/3c7c49af-00a4-3bcd-bc00-20e7f0f1b7bf", info="https://gdi.berlin.de/geonetwork/srv/ger/catalog.search#/metadata/3c7c49af-00a4-3bcd-bc00-20e7f0f1b7bf",
license="dl-de/zero-2-0", license="dl-de/zero-2-0",
) )
if __name__ == "__main__":
atom_path = TMP_DIR / f"{BERLIN}.atom"
download_file(BERLIN.source, TMP_DIR / atom_path)
tree = ET.parse(atom_path)
root = tree.getroot()
zip_files = []
ns = {"atom": "http://www.w3.org/2005/Atom"}
updated_node = root.find("atom:updated", ns)
if updated_node is None:
raise ValueError("No date has been found")
updated_date = updated_node.text
if updated_date is None:
raise ValueError("No date has been found")
source_date = datetime.strptime(updated_date, "%Y-%m-%dT%H:%M:%SZ")
for file_elem in root.findall("atom:entry/atom:link", ns):
href = file_elem.attrib["href"]
if href.endswith(".zip"):
zip_files.append(
ZipFile(
url=href,
bundesland=BERLIN,
source_date=source_date,
)
)
download_all_files(zip_files)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment