diff --git a/backend/news_fetcher.py b/backend/news_fetcher.py index 40fac76..37faf96 100644 --- a/backend/news_fetcher.py +++ b/backend/news_fetcher.py @@ -113,11 +113,17 @@ class NewsFetcher: """Save articles to JSON file""" timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") filename = f"news_{timestamp}.json" - filepath = os.path.join(self.raw_news_dir, filename) - + + # Normalize the path to avoid double backslashes + raw_news_dir = os.path.normpath(self.raw_news_dir) + filepath = os.path.normpath(os.path.join(raw_news_dir, filename)) + + # Ensure directory exists + os.makedirs(raw_news_dir, exist_ok=True) + with open(filepath, 'w', encoding='utf-8') as f: json.dump(articles, f, indent=2, ensure_ascii=False) - + print(f"Saved {len(articles)} articles to {filepath}") return filepath