中国天气网各接口地址

本文详细介绍了如何从多个API获取中国的天气预报信息,包括省份列表、市(地区)列表、县列表以及天气详情等,同时提供了城市ID查询功能,并展示了如何通过城市名、全拼、简拼、电话区号、邮编查询城市对应ID。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、省份列表:
http://weather.com.cn/data/city3jdata/china.html

2、根据省ID 获取市(地区)列表:
http://weather.com.cn/data/city3jdata/provshi/.html
http://weather.com.cn/data/listinfo/city.xml
id = 省份ID (101 + 两位数字01~34)
sid = 省份ID 后两位

如:http://weather.com.cn/data/city3jdata/provshi/10111.html
{“01″:”西安”,”02″:”咸阳”,”03″:”延安”,”04″:”榆林”,”05″:”渭南”,”06″:”商洛”,”07″:”安康”,”08″:”汉中”,”09″:”宝鸡”,”10″:”铜川”,”11″:”杨凌”}

如:http://weather.com.cn/data/listinfo/city11.xml
1101|西安,1102|咸阳,1103|延安,1104|榆林,1105|渭南,1106|商洛,1107|安康,1108|汉中,1109|宝鸡,1110|铜川,1111|杨凌


3、根据市(地区)ID 获取县列表:
http://weather.com.cn/data/city3jdata/station/.html
http://weather.com.cn/data/listinfo/city.xml
id = 省份ID + 市(地区)ID
sid = 省份ID 后两位 + 市(地区)ID

如:http://weather.com.cn/data/city3jdata/station/1011101.html
{“01″:”西安”,”02″:”长安”,”03″:”临潼”,”04″:”蓝田”,”05″:”周至”,”06″:”户县”,”07″:”高陵”}

如:http://weather.com.cn/data/listinfo/city1101.xml
110101|西安,110102|长安,110103|临潼,110104|蓝田,110105|周至,110106|户县,110107|高陵

4、根据ID,获取天气详情:
详情:http://m.weather.com.cn/data/.html
概要:http://weather.com.cn/data/cityinfo/.html

ID = 省份ID + 市(地区)ID + 县ID
如:http://m.weather.com.cn/data/101110101.html
http://weather.com.cn/data/cityinfo/101110101.html

国外貌似都是以40开头的ID,如 纽约:401110101
http://m.weather.com.cn/data/401110101.html
http://weather.com.cn/data/cityinfo/401110101.html

5、根据城市名、全拼、简拼、电话区号、邮编查询、英文(国外)获取城市对应ID:
http://t.weather.com.cn/SearchBox/searchBox?callback=&_=&language=&keyword=
包含4个参数,callback、_、language、keyword
calkback:若为空,则返回json格式,否则返回callback的jsonp;
_:时间戳,精确到毫秒,js可以直接输出这个值;
language:语言,可选 zh|en ,默认 zh;
keyword:关键词,可输入城市名、全拼、简拼、电话区号、邮编查询。如 ny 返回:
{“f”:[{"n":"纽约","m":"NY","d":"美国","i":"401110101","t":"f"}],”i”:[{"n":"南阳","m":"NY","d":"河南","i":"101180701","t":"i"},{"n":"南岳","m":"NY","d":"湖南","i":"101250409","t":"i"},{"n":"纳雍","m":"NY","d":"贵州","i":"101260706","t":"i"},{"n":"宁阳","m":"NY","d":"山东","i":"101120806","t":"i"},{"n":"宁远","m":"NY","d":"湖南","i":"101251406","t":"i"}]}

6、xml天气
http://flash.weather.com.cn/wmaps/xml/china.xml
各省份列表及天气。
http://flash.weather.com.cn/wmaps/xml/ .xml
市级天气信息。

转载于:https://my.oschina.net/zhengjian/blog/170772

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值