yin_home/utils/query_weather.py
2025-02-11 16:04:10 +08:00

13 lines
388 B
Python

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