Skip to content

Commit

Permalink
ensure save dir exists
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxDall committed Feb 12, 2025
1 parent 234cf31 commit 98dee2c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/fundus/scraping/crawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,9 @@ def callback() -> None:
finally:
session_handler.close_current_session()
if save_to_file is not None:
if isinstance(save_to_file, str):
save_to_file = Path(save_to_file)
save_to_file.parent.mkdir(parents=True, exist_ok=True)
with open(save_to_file, "w", encoding="utf-8") as file:
logger.info(f"Writing crawled articles to {save_to_file!r}")
file.write(
Expand Down

0 comments on commit 98dee2c

Please sign in to comment.