# -*- coding: utf-8 -*-

import requests
import json

def scarica_json(url, nome_file):
    try:
        # Send a GET request to the URL
        response = requests.get(url)
        
        # Check if the request was successful
        if response.status_code == 200:
            # Download the JSON content
            dati_json = response.json()
            with open(nome_file, 'w', encoding='utf-8') as file:
                json.dump(dati_json, file, ensure_ascii=False, indent=4)
            print(f"JSON has been saved to the file: {nome_file}")
        else:
            print(f"Unable to download JSON. Status code: {response.status_code}")
    except Exception as e:
        print(f"An error occurred: {e}")

# URL of the JSON to download
url = "https://onefootball.com/proxy-web-experience/it/partita/2524509"

# Name of the JSON file to save
nome_file = "one.json"

# Download the JSON and save it to the file
scarica_json(url, nome_file)
