Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- # Hacer un script que muestra la cotización del dolar actualizada
- import requests
- from pprint import pprint
- from datetime import datetime
- '''
- url = "https://www.dolarsi.com/api/api.php?type=valoresprincipales"
- r = requests.get(url)
- # pprint(r.json())
- for item in r.json():
- print(f"""
- Activo: {item['casa']['nombre']}
- Precio de venta: {item['casa']['venta']}
- Precio de compra: {item['casa']['compra']}
- """)
- '''
- lat = -38.416097
- lon = -63.616672
- API_key = "db7ba55a8af3d8d738d88349a7c9380d"
- url = f"https://api.openweathermap.org/data/2.5/forecast?lat={lat}&lon={lon}&units=metric&lang=es&appid={API_key}"
- r = requests.get(url)
- lista = r.json()["list"]
- for item in lista:
- print(f"""
- Hora: {datetime.fromtimestamp(item['dt'])}
- Descripción: {item['weather'][0]['description']}
- Temperatura: {item['main']['temp']}ºC
- Sensacion termica: {item['main']['feels_like']}ºC
- Velocidad del viento: {item['wind']['speed']} km/h
- Presion atm: {item['main']['pressure']} HPa
- Humedad relativa ambiente: {item['main']['humidity']}%
- """)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement