From 28ec8afa7741e41e8d9b7a5b8ffe1737c5d08647 Mon Sep 17 00:00:00 2001 From: Tykayn Date: Thu, 4 Sep 2025 23:03:48 +0200 Subject: [PATCH] up scraping --- wiki_compare/wiki_compare.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/wiki_compare/wiki_compare.py b/wiki_compare/wiki_compare.py index abb6ea1..294b61b 100755 --- a/wiki_compare/wiki_compare.py +++ b/wiki_compare/wiki_compare.py @@ -214,13 +214,18 @@ def save_to_json(data, filename): # Print the JSON string for debugging logger.info(f"JSON string to be written to {filename}:") - logger.info(f"JSON keys at top level: {list(data.keys())}") - if 'translations' in data: - logger.info(f"JSON keys in translations: {list(data['translations'].keys())}") - if 'type' in data['translations']: - logger.info(f"'type' key exists in translations") - if 'type_key' in data['translations']: - logger.info(f"'type_key' key exists in translations") + + # Check if data is a dictionary before trying to access keys + if isinstance(data, dict): + logger.info(f"JSON keys at top level: {list(data.keys())}") + if 'translations' in data: + logger.info(f"JSON keys in translations: {list(data['translations'].keys())}") + if 'type' in data['translations']: + logger.info(f"'type' key exists in translations") + if 'type_key' in data['translations']: + logger.info(f"'type_key' key exists in translations") + elif isinstance(data, list): + logger.info(f"Data is a list with {len(data)} items") # Write the JSON string to the file with open(filename, 'w', encoding='utf-8') as f: