免费的接口有好多,但是容易在单片机上实现的不太多了。有些已经用https协议了。比如:
付费:https://api.heweather.com/s6/weather/now?[parameters]
免费:https://free-api.heweather.com/s6/weather/now?[parameters]
前两天经过实际验证,下边合格接口简单一些,返回JSON格式数据,解析也简单。
#define AREA_ID "101100501"
#define GET_URI "http://www.weather.com.cn/data/sk/%s.html"
把AREA_ID和GET_URI进行拼接就可以(%su用AREA_ID 代替)。AREA_ID代表城市编码,百度文库有。返回数据是这样的:
{"weatherinfo":{"city":"闀挎不""cityid":"101100501""temp":"22.2""WD":"鍗楅""WS":"灏忎簬3绾�""SD":"28%""AP":"897.3hPa""njd":"鏆傛棤瀹炲喌""WSE":"<3""time":"17:00""sm":"1.8""isRadar":"0""Radar":""}}
编码问题,有乱码,见谅。