参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
appkey | string | 是 | |
city | string | 否 | 城市名(如“杭州”),需UTF-8编码 |
cityid | int | 否 | 城市ID |
citycode | string | 否 | 城市天气代号(如“101260301”) |
location | string | 否 | 经纬度,格式为“纬度,经度”(如“39.983424,116.322987”) |
ip | string | 否 | 查询IP所在城市天气 |
注意:city、cityid、citycode、location、ip参数四选一,不传则默认返回当前IP城市天气。
import requests # 配置参数 params = { "appkey": "your_appkey_here", # 替换为实际appkey "city": "杭州" } # 发送请求 url = "https://api.jisuapi.com/weather/query" response = requests.get(url, params=params) data = response.json() # 错误处理 if data["status"] != 0: print(f"请求失败:{data['msg']}") exit() result = data["result"] # 解析实时天气 print(f"城市:{result['city']} 日期:{result['date']} 天气:{result['weather']}") print(f"温度:{result['temp']}℃ 最高温:{result['temphigh']}℃ 最低温:{result['templow']}℃") # 解析7天预报 print("\n未来7天预报:") for day in result["daily"]: print(f"{day['date']} {day['week']}: 白天{day['day']['weather']} {day['day']['temphigh']}℃, 夜间{day['night']['weather']} {day['night']['templow']}℃") # 解析空气质量 aqi = result["aqi"] print(f"\n空气质量:{aqi['quality']} AQI:{aqi['aqi']} 首要污染物:{aqi['primarypollutant']}")
天气数字ID图标展示地址:https://www.jisuapi.com/demo/weather/icon,下载地址:http://api.jisuapi.com/weather/icon.zip
极速数据天气预报API,覆盖面广,更新及时,服务稳定,返回数据完备。支持各种方式查询,返回标准的JSON格式,提供多种语言示例,方便开发者快速接入天气服务。同时天气的价格只有48元/100000次,性价比高。极速数据同时提供快速、周到的技术服务,为您的开发工作保驾护航。
© 2015-2024 杭州极速互联科技有限公司 版权所有 浙ICP备17047587号-4 浙公网安备33010502005096 增值电信业务经营许可证:浙B2-20190875