From d4cf254df661412390e315be3a803e2fb6f78028 Mon Sep 17 00:00:00 2001 From: Marc Nixon Date: Fri, 1 Sep 2023 10:42:04 -0700 Subject: [PATCH] json output into run_all again --- snowscraper/controller.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/snowscraper/controller.py b/snowscraper/controller.py index 386a028..f6d8864 100644 --- a/snowscraper/controller.py +++ b/snowscraper/controller.py @@ -17,15 +17,15 @@ def run_all(args: argparse.Namespace): results.update(scraper.scrape()) print(results) + # Save the results to a JSON file + with open('results.json', 'w') as json_file: + json.dump(results, json_file, indent=4, default=datetime_handler) + def datetime_handler(obj): if isinstance(obj, datetime.datetime): return obj.isoformat() raise TypeError("Unknown type") -# Save the results to a JSON file -with open('results.json', 'w') as json_file: - json.dump(results, json_file, indent=4, default=datetime_handler) - def import_scrapers(): directory = Path(__file__).resolve().parent / "scrapers" for module_loader, name, ispkg in pkgutil.iter_modules([directory]):