网上关于免费天气api接口很多,本人总结了一下目前还可用的免费api接口和已失效的接口如下:
目前可用接口:
1、讯飞语音识别内置的墨迹天气API。链接:
http://autodev.openspeech.cn/csp/api/v2.1/weather?openId=aiuicus&clientType=android&sign=android&city=上海&latitude=39.902895&longitude=116.427915&needMoreData=true&pageNo=1&pageSize=7
可根据城市名及经纬度查询天气,数据还不错。比需要申请的天气差一点,但基本能满足需要,是目前比较好的数据源。
{"code":0,"msg":"操作成功","data":{"total":7,"sourceName":"墨迹天气","list":[{"city":"深圳","lastUpdateTime":"2022-12-12 00:55:08","date":"2022-12-12","weather":"多云","temp":12.0,"humidity":"65%","wind":"北风3级","pm25":50.0,"pm10":52.0,"low":12.0,"high":18.0,"airData":"52","airQuality":"良","dateLong":1670774400000,"weatherType":1,"windLevel":3,"province":"广东","moreData":{"sunrise":"2022-12-12 06:54:00","sunset":"2022-12-12 17:41:00","precipitation":"0","alert":null}},{"city":"深圳","lastUpdateTime":"2022-12-11 23:07:00","date":"2022-12-13","weather":"阴","humidity":"未知","wind":"北风","pm25":0.0,"low":11.0,"high":16.0,"airData":"45","airQuality":"优","dateLong":1670860800000,"weatherType":2,"windLevel":3,"province":"广东","moreData":{"sunrise":"2022-12-13 06:55:00","sunset":"2022-12-13 17:41:00","precipitation":null,"alert":null}},{"city":"深圳","lastUpdateTime":"2022-12-11 23:07:00","date":"2022-12-14","weather":"小雨","humidity":"未知","wind":"东北风","pm25":0.0,"low":11.0,"high":13.0,"airData":"37","airQuality":"优","dateLong":1670947200000,"weatherType":7,"windLevel":3,"province":"广东","moreData":{"sunrise":"2022-12-14 06:55:00","sunset":"2022-12-14 17:41:00","precipitation":null,"alert":null}},{"city":"深圳","lastUpdateTime":"2022-12-11 23:07:00","date":"2022-12-15","weather":"小雨","humidity":"未知","wind":"微风","pm25":0.0,"low":11.0,"high":14.0,"airData":"36","airQuality":"优","dateLong":1671033600000,"weatherType":7,"windLevel":2,"province":"广东","moreData":{"sunrise":"2022-12-15 06:56:00","sunset":"2022-12-15 17:42:00","precipitation":null,"alert":null}}],"logoUrl":"http://iflycar.hfdn.openstorage.cn/xfypicture/dev/logo/moji.png"}}
2、中国天气网API接口.
html数据:
http://flash.weather.com.cn/wmaps/xml/beijing.xml
json数据:
http://www.weather.com.cn/data/sk/101010100.html
http://www.weather.com.cn/data/cityinfo/101010100.html
图标数据:
http://m.weather.com.cn/img/c0.gif
http://m.weather.com.cn/img/b0.gif
http://www.weather.com.cn/m/i/weatherpic/29x20/d0.gif
http://www.weather.com.cn/m2/i/icon_weather/29x20/n00.gif
数据源质量一般,json用的GBK编码,数据处理可能麻烦点。也可以用。
html数据:
json数据:
{"weatherinfo":{"city":"北京","cityid":"101010100","temp1":"18℃","temp2":"31℃","weather":"多云转阴","img1":"n1.gif","img2":"d2.gif","ptime":"18:00"}}
目前只发现这两个api还可用。
下面是已失效的api接口:
1.中华万年历的天气API
http://wthrcdn.etouch.cn/WeatherApi?city=上海
2.蚂蚁数据API接口。已被别人整合。
其他和风、知心、丫丫等很多就需要注册,需要key.