diff --git a/DataImporter.py b/DataImporter.py index eeefbecaa391aa26f2413d9c64d66a1751414e02..b021da41b9d65c291f4c0791100e2c8a90358370 100644 --- a/DataImporter.py +++ b/DataImporter.py @@ -38,7 +38,10 @@ class DataImporter(DataHandler, ABC): apiRootUrl: string = "https://en.wikipedia.org/wiki/" grandPrixName: string = f"{event.year} {event["EventName"]}" uri: string = re.sub(" ", "_", grandPrixName) - response = requests.get(f"{apiRootUrl}{uri}") + url: string = f"{apiRootUrl}{uri}" + response = requests.get(url) + if not response.ok: + raise ConnectionError(f"Could not fetch wikipedia article with URL {url}") return response.text # URL example to get 2024 Sao Paulo GP: https://en.wikipedia.org/w/api.php?action=query&titles=2024_S%C3%A3o_Paulo_Grand_Prix&prop=extracts&format=json&exintro=1