Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- import requests
- from datetime import datetime
- from pprint import pprint
- url = "https://api.openweathermap.org/data/2.5/weather?q=Buenos%20Aires,AR&units=metric&lang=es&appid=6ce13bc6d5a965e991adaea8fce8676a"
- r = requests.get(url)
- datos = r.json()
- pprint(datos)
- # muestro la hora del pronòstico (timestamp)
- horario = datetime.fromtimestamp(datos['dt'])
- print(f"Hora del pronostico: {horario}")
- # muestro el horario de la salida del sol
- amanecer = datetime.fromtimestamp(datos['sys']['sunrise'])
- print(f"Amanecer: {amanecer}")
- # muestro el horario del ocaso
- ocaso = datetime.fromtimestamp(datos['sys']['sunset'])
- print(f"Ocaso: {ocaso}")
- print("------------------------------------------------")
- url2 = "https://api.openweathermap.org/data/2.5/onecall?lat=-34.61&lon=-58.38&units=metric&lang=es&appid=6ce13bc6d5a965e991adaea8fce8676a"
- r = requests.get(url2)
- datos = r.json()
- pprint(datos)
- print("---------------")
- print(datos)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement