Last active
July 27, 2023 17:41
-
-
Save sergiolucero/07161f6584ec1c2e341db96c7da5f519 to your computer and use it in GitHub Desktop.
Precios combustibles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
from token import TOKEN # token personal: http://www.energiaabierta.cne.cl/ | |
TIPOS = ['calefaccion','vehicular'] | |
SOURCE = 'http://api.cne.cl/v3/combustibles/{}/estaciones?token={}' | |
COPY_VARS = ['nombre_comuna', 'id_region', 'direccion_calle', 'fecha_hora_actualizacion'] | |
for tipo in TIPOS: | |
print(tipo) | |
df = pd.read_json(SOURCE.format(tipo, TOKEN)) | |
out = pd.DataFrame() | |
for did, drow in df.iterrows(): | |
dd = drow['data'] | |
dout = dd['precios'] #{'gasolina 93': 800,...} | |
dout.update(dd['servicios']) | |
dout.update(dd['ubicacion']) | |
for var in COPY_VARS: | |
dout[var] = dd[var] | |
out = out.append(pd.DataFrame(dout, index=[did])) | |
print(out.head()) |
Faltan los call centers de gas licuado:
http://api.cne.cl/v3/combustibles/calefaccion/callcenters?token=[TOKEN]
Algún tip sobre como conseguir el token de sesión?
Tengo la misma duda, como puedo conseguir el token?
No estoy seguro, pero al parecer hay que enviar un formulario en la página de la CNE.
una pregunta, a alguno le ha funcionado esta api??
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Las estaciones de bencina de la Región de Los Ríos.