yin_home/utils/query_weather.py

15 lines
468 B
Python
Raw Normal View History

2025-02-11 16:04:10 +08:00
import requests
2025-02-11 18:03:58 +08:00
from utils.log import Log
2025-02-11 16:04:10 +08:00
def query_weather(key="3add99f10c5144ebd64bfa0bfb6b1c20", city="420115", extensions="base", output="JSON"):
2025-02-11 18:03:58 +08:00
log = Log().getlog()
2025-02-11 16:04:10 +08:00
url = "https://restapi.amap.com/v3/weather/weatherInfo"
querystring = {"key": key, "city": city, "extensions": extensions,
"output": output}
response = requests.request("GET", url, params=querystring)
2025-02-11 18:03:58 +08:00
log.info(response.json())
2025-02-11 16:04:10 +08:00
return response.json()