From 12ab7cff73094b2c3e72153dd79771f72f53d7f5 Mon Sep 17 00:00:00 2001 From: Mazztok45 Date: Mon, 11 Nov 2024 17:58:05 +0100 Subject: [PATCH] fixing issue in the code syntax and looping strategy with the help --- src/zbmath_rest2oai/getAsXml.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/zbmath_rest2oai/getAsXml.py b/src/zbmath_rest2oai/getAsXml.py index af1634b..7779df3 100644 --- a/src/zbmath_rest2oai/getAsXml.py +++ b/src/zbmath_rest2oai/getAsXml.py @@ -89,10 +89,12 @@ def final_xml2(api_source, prefix): soft_id=api_source.split("/")[-1] list_articles_ids_to_soft=[] def api_doc_endpoint(page): - return requests.get("https://api.zbmath.org/v1/document/_structured_search?page={}&results_per_page=100&software%20id=".format(page)+soft_id) + return requests.get("https://api.zbmath.org/v1/document/_structured_search?page={}&results_per_page=100&software%20id=".format(page,soft_id)) page=0 - while api_doc_endpoint["result"]!=None: + while True: data = api_doc_endpoint(page) + if data is None or "result" not in data or not data["result"]: + break list_articles_ids_to_soft.extend([entry["id"] for entry in data["result"]]) page+=1 for result in json["result"]: