yin_home/utils/query_weather.py
2025-02-11 18:03:58 +08:00

15 lines
468 B
Python

import requests
from utils.log import Log
def query_weather(key="3add99f10c5144ebd64bfa0bfb6b1c20", city="420115", extensions="base", output="JSON"):
log = Log().getlog()
url = "https://restapi.amap.com/v3/weather/weatherInfo"
querystring = {"key": key, "city": city, "extensions": extensions,
"output": output}
response = requests.request("GET", url, params=querystring)
log.info(response.json())
return response.json()