From b04b1370ccbf67b7090173b0651fd857ded37034 Mon Sep 17 00:00:00 2001 From: Simon Vetter Date: Mon, 26 Aug 2024 09:55:26 +0200 Subject: [PATCH] Create missing directory when scraping --- scrape.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scrape.py b/scrape.py index 3d71215..e682859 100644 --- a/scrape.py +++ b/scrape.py @@ -85,6 +85,9 @@ sep = ',' +# Make sure directory exists +os.makedirs(os.path.dirname(results_filepath), exist_ok=True) + with open(results_filepath, 'w', encoding='UTF-8', newline='\n') as f: f.write(sep.join(["Check-in date", "Check-out date", "Room description", "Room capacity", "Meals", "Price", "Number available", "felix-id", "package-id", "room-id", "name-param", "Scrape date"]) + '\n')