Skip to content
Snippets Groups Projects
Commit 519f3015 authored by Lennard Geese's avatar Lennard Geese
Browse files

Add exception for bad requests

parent 14e51fe3
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment