Esta página web ejecuta en tiempo real el algoritmo de consulta geográfica y expone el script homólogo desarrollado para terminales Python.
El sistema establece una conexión directa por medio de peticiones estructuradas HTTPS hacia la API pública del Servicio Geológico de los Estados Unidos (USGS).
&limit=8) según la interacción.Y-m-d H:i para renderizar "Año-Mes-Día Hora:Minutos" (ej: 2026-05-31 18:42).Resultados capturados bajo demanda por este servidor:
| Magnitud | Hora Chile (GMT-3) | Ubicación |
|---|---|---|
| 5.1 | 2026-06-05 03:54 | 103 km NNW of Villa General Roca, Argentina |
| 4.1 | 2026-06-04 18:59 | 90 km ESE of La Tirana, Chile |
| 4.1 | 2026-06-03 19:36 | 56 km WSW of San Antonio, Chile |
| 4.2 | 2026-06-03 11:10 | 42 km SSW of Ollagüe, Chile |
| 4.2 | 2026-06-02 06:53 | 81 km WSW of Illapel, Chile |
| 4.5 | 2026-06-02 03:13 | 68 km NNE of La Serena, Chile |
| 4.2 | 2026-05-31 19:18 | 28 km NE of San Martín, Argentina |
| 4.4 | 2026-05-31 19:09 | 34 km NNW of Valparaíso, Chile |
Este script ejecuta de manera nativa en consola el mismo mapeo. Se utilizan códigos ANSI para pintar la terminal según la magnitud.
import requests
from datetime import datetime, timezone, timedelta
# Códigos ANSI para colores en consola
VERDE = '\033[92m'
NARANJO = '\033[93m'
ROJO = '\033[91m'
MORADO = '\033[95m'
RESET = '\033[0m'
print("====================================================")
print(" MONITOR DE SISMOS EN TIEMPO REAL - CHILE")
print("====================================================")
try:
limite_sismos = input("¿Cuántos sismos deseas visualizar? (Por defecto 8): ")
limite = int(limite_sismos) if limite_sismos.strip().isdigit() else 8
except ValueError:
limite = 8
print(f"\nConectando con el Servicio Geológico (USGS) para traer {limite} registros...")
url = "https://earthquake.usgs.gov/fdsnws/event/1/query"
params = {
"format": "geojson",
"minlatitude": "-56.0",
"maxlatitude": "-17.5",
"minlongitude": "-76.0",
"maxlongitude": "-66.0",
"limit": str(limite)
}
try:
res = requests.get(url, params=params, timeout=10)
datos = res.json()
sismos = datos.get("features", [])
print(f"\n{'MAGNITUD':<9} | {'HORA CHILE (GMT-3)':<18} | {'UBICACIÓN'}")
print("-" * 65)
for sismo in sismos:
prop = sismo["properties"]
mag = prop["mag"]
lugar = prop["place"]
timestamp = prop["time"] / 1000
fecha_utc = datetime.fromtimestamp(timestamp, timezone.utc)
fecha_chile = fecha_utc - timedelta(hours=3)
fecha_legible = fecha_chile.strftime('%Y-%m-%d %H:%M')
color_consola = RESET
if mag is not None:
if mag < 3.0:
color_consola = VERDE
elif 3.0 <= mag <= 4.5:
color_consola = NARANJO
elif 4.6 <= mag <= 7.0:
color_consola = ROJO
elif mag > 7.0:
color_consola = MORADO
mag_str = f"{mag:.1f}" if mag is not None else "N/A"
print(f"{color_consola}{mag_str:<9}{RESET} | {fecha_legible:<18} | {lugar}")
except Exception as e:
print(f"\nError de red o conexión: {e}")
print("====================================================")
input("\nPresiona Enter para cerrar...")