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
- # current weather data
- url = "https://api.openweathermap.org/data/2.5/weather?q=Buenos%20Aires&units=metric&lang=es&appid=6ce13bc6d5a965e991adaea8fce8676a"
- r = requests.get(url)
- data = r.json()
- pprint(data)
- print("Fecha y hora:")
- print(datetime.fromtimestamp(data['dt']))
- print("Salida del Sol:")
- print(datetime.fromtimestamp(data['sys']['sunrise']))
- print("Puesta del Sol:")
- print(datetime.fromtimestamp(data['sys']['sunset']))
- # one call API
- url = 'https://api.openweathermap.org/data/2.5/onecall?lat=-34.61&lon=-58.38&units=metric&lang=es&exclude={current,minutely,hourly}&appid=6ce13bc6d5a965e991adaea8fce8676a'
- r = requests.get(url)
- data = r.json()
- pprint(data)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement