def obtenerValor():
    session = Session()
    session.headers.update(headers)

    try:
        response = session.get(url, params=parameters)
        data = json.loads(response.text)
        #print (json.dumps(data,indent=4))
        #insertar valor en tablas
        ausiliar = 0
        for curso in data['data']:
            precio1 = float(curso['quote']['USD']['price'])
            Volumen_24h1 = float(curso['quote']['USD']['volume_24h'])
            Cambio_1h1 = float(curso['quote']['USD']['percent_change_1h'])
            Cambio_24h1 = float(curso['quote']['USD']['percent_change_24h'])
            Cambio_7d1 = float(curso['quote']['USD']['percent_change_7d'])
            Capitalizacion1 = float(curso['quote']['USD']['market_cap'])
            Ultima_actualizacion1 = str(curso['quote']['USD']['last_updated'])
            models.insertInTableValor(precio1, Volumen_24h1, Cambio_1h1,
                                      Cambio_24h1, Cambio_7d1, Capitalizacion1,
                                      Ultima_actualizacion1, (ausiliar + 760))
            insertar_datos(precio1, Ultima_actualizacion1, ausiliar)
            limpiar_datos(data2)
            #Escribir_datos(data2)
            ausiliar += 1

    except (ConnectionError, Timeout, TooManyRedirects) as e:
        print(e)
def obtenerValor():
    session = Session()
    session.headers.update(headers)

    try:
        response = session.get(url, params=parameters)
        data = json.loads(response.text)
        #print (json.dumps(data,indent=4))
        #insertar valor en tablas
        for curso in data['data']:
            tempos = list(curso.items())
            moneda = tempos[2]
            for x in curso.get('quote').values():
                zips = list(x.items())
                precio1 = zips[3][1]
                Volumen_24h1 = zips[5][1]
                Cambio_1h1 = zips[6][1]
                Cambio_24h1 = zips[4][1]
                Cambio_7d1 = zips[2][1]
                Capitalizacion1 = zips[0][1]
                Ultima_actualizacion1 = zips[1][1]
                models.insertInTableValor(precio1, Volumen_24h1, Cambio_1h1,
                                          Cambio_24h1, Cambio_7d1,
                                          Capitalizacion1,
                                          Ultima_actualizacion1)
                data2['valorx'] = []
                data2['valory'] = []
                data2['valorx'].append(Ultima_actualizacion1)
                data2['valory'].append(precio1)
                with open('data.json', 'w') as file:
                    json.dump(data2, file, indent=4)

    except (ConnectionError, Timeout, TooManyRedirects) as e:
        print(e)