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
- r = requests.get("https://api.openweathermap.org/data/2.5/weather?q=Buenos%20Aires&units=metric&lang=es&appid=6ce13bc6d5a965e991adaea8fce8676a")
- datos = r.json()
- pprint(datos)
- print("Hora del pronostico")
- hora = datetime.fromtimestamp(datos['dt'])
- print(hora)
- print("Amanecer")
- hora = datetime.fromtimestamp(datos['sys']['sunrise'])
- print(hora)
- print("Ocaso")
- hora = datetime.fromtimestamp(datos['sys']['sunset'])
- print(hora)
- """
- {'base': 'stations',
- 'clouds': {'all': 0},
- 'cod': 200,
- 'coord': {'lat': -34.6132, 'lon': -58.3772},
- 'dt': 1630183626,
- 'id': 3435910,
- 'main': {'feels_like': 17.64,
- 'humidity': 62,
- 'pressure': 1023,
- 'temp': 18.15,
- 'temp_max': 21.63,
- 'temp_min': 15.85},
- 'name': 'Buenos Aires',
- 'sys': {'country': 'AR',
- 'id': 8224,
- 'sunrise': 1630145853,
- 'sunset': 1630186335,
- 'type': 1},
- 'timezone': -10800,
- 'visibility': 10000,
- 'weather': [{'description': 'cielo claro',
- 'icon': '01d',
- 'id': 800,
- 'main': 'Clear'}],
- 'wind': {'deg': 110, 'speed': 4.12}}
- """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement