Advertisement
teslariu

openweather

Feb 24th, 2022
919
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # openweathermap.org
  5. import requests
  6. from datetime import datetime
  7. from pprint import pprint
  8.  
  9. r = requests.get("http://api.openweathermap.org/data/2.5/weather?lat=-34.61&lon=58.38&lang=es&units=metrics&appid=6ce13bc6d5a965e991adaea8fce8676a")
  10. datos = r.json()
  11. pprint(datos)
  12.  
  13. # Hora del pronostico
  14. print(datetime.fromtimestamp(datos['dt']))
  15.  
  16. # salida del sol y puesta del sol
  17. print(datetime.fromtimestamp(datos['sys']['sunrise']))
  18. print(datetime.fromtimestamp(datos['sys']['sunset']))
  19.  
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement