tg4/Chapitre 3 - Modularité/requettes.py

10 lines
474 B
Python
Raw Permalink Normal View History

2023-11-08 10:26:32 +00:00
import requests
import json
url = 'https://api.openweathermap.org/data/2.5/weather'
reponse = requests.get(url+'?q=Paris&appid=0001aa32345d1df47456f64b45f8170b')
print(reponse.json())
2023-11-08 10:34:17 +00:00
from pyowm.owm import OWM
manager = OWM('0001aa32345d1df47456f64b45f8170b').weather_manager() # obtenir un accès au site
observation = manager.weather_at_place('Paris') # obtenir la météo d'une ville
print(observation.weather.status, observation.weather.temperature('celsius'))