Advertisement
teslariu

openweather

Dec 11th, 2021
836
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # Script para automatizar descargar del pronóstico
  5.  
  6. import requests
  7. from datetime import datetime
  8. from pprint import pprint
  9.  
  10. url = "https://api.openweathermap.org/data/2.5/weather?q=Buenos%20Aires,AR&units=metric&lang=es&appid=6ce13bc6d5a965e991adaea8fce8676a"
  11.  
  12. r = requests.get(url)
  13. datos = r.json()
  14. pprint(datos)
  15.  
  16. print("\nHora del pronóstico")
  17. print(datetime.fromtimestamp(datos['dt']))
  18.  
  19. print("\nSalida del Sol")
  20. print(datetime.fromtimestamp(datos['sys']['sunrise']))
  21.  
  22. print("\nPuesta del Sol")
  23. print(datetime.fromtimestamp(datos['sys']['sunset']))
  24.  
  25. print("\nTemperatura:")
  26. print("{:.1f}ºC".format(datos['main']['temp']))
  27.  
  28. print("\nSensación térmica:")
  29. print("{:.1f}ºC".format(datos['main']['feels_like']))
  30.  
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement