up scraping
This commit is contained in:
parent
3bfd4b77d4
commit
28ec8afa77
1 changed files with 12 additions and 7 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue