现在关于天气预报的手机应用是非常的多,包括那些非常著名的应用(我就不指名了,大家应该都用过),我就纳了闷了,一个预报天气的应用把天气好好的预报了就得了呗,非得加那么多没有用的功能,弄得应用本身越来越臃肿,而且速度越来越慢,你们到底要干什么吗?
于是准备自己做一个专注天气预报的应用程序。
首先要解决的就是关于天气数据来源的问题。现在关于天气的 API 很多,不过,得到的数据要么是太少,要么就是不完全。于是我就准备自己从权威网站上抓取数据,从而获得天气信息。
于是乎,我就选取了从 “中国天气网 -
www.weather.com.cn” 获取数据。也许天气数据可能关乎国家安全(网上有人是这么说的啊~~~嘿嘿!),所以权威网站一般都不直接提供天气的 API,于是我就自己分析了一下该网站的,得到了如下一些 API,有了这些 API,我就可以取得任何城市的天气信息了。
API 如下:
1. 获取中图首都,直辖市,自治区,省会信息(provid):
http://www.weather.com.cn/data/city3jdata/china.html
2. 获取市,地区信息(districtid):
http://www.weather.com.cn/data/city3jdata/provshi/[provid].html
例如:
http://www.weather.com.cn/data/city3jdata/provshi/10107.html
3. 获取区信息(cityid):
若 provid 为 "10101 北京","10102 上海","10103 天津","10104 重庆",则获取区的 API 为
http://www.weather.com.cn/data/city3jdata/station/[provid]00.html
例如:
http://www.weather.com.cn/data/city3jdata/station/1010100.html
其它情况,API 为
http://www.weather.com.cn/data/city3jdata/station/[provid][districtid].html
例如:
http://www.weather.com.cn/data/city3jdata/station/1010702.html
4. 获取天气信息:
若 provid 为 "10101 北京","10102 上海","10103 天津","10104 重庆",则获取天气的 API 为
http://www.weather.com.cn/weather/[provid][cityid]00.shtml
例如:
http://www.weather.com.cn/weather/101010200.shtml
其它情况,API 为
http://www.weather.com.cn/weather/[provid][districtid][cityid].shtml
例如:
http://www.weather.com.cn/weather/101070201.shtml
根据以上 API 结合 GPS 信息,就可以获取任何城市的天气信息了。
大功告成!
分享到:
相关推荐
python编程。入门到实践的sitka_weather_07-2014.csv文件
yahoo_weather-5.x-1.x-dev.tar.gz
gsm-weather-s3-simulator-master.zip
weatherApi-源码.rar
微信小程序开发的天气预报weather-master.zip
微信小程序-蜗牛天气源码wxWeather-master.zip
React-city-weather-源码.rar
安卓天气预报android-weather.zip
matlab批量获取全国各城市实时天气数据函数-weather.m 本帖最后由 gasongjian 于 2013-10-27 17:12 编辑 matlab 批量获取全国各城市实时天气数据函数(matlab2011b) 下面的代码是独立的函数,可根据城市id...
开源项目-guitmz-go-weather-indicator.zip,GTK weather indicator I wrote in GoLang, hope you find it interesting
Weather Icons 是唯一具有 222 个天气主题图标的图标字体和 CSS,可以直接放入Bootstrap或任何需要高质量天气、海事和气象图标的项目。
前端项目-weather-icons,215 weather themed icons inspired by Font Awesome and ready for Bootstrap
很好
python_sitka_weather_07-2014.csv
资源分类:Python库 所属语言:Python 资源全名:Open Weather API-1.0.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059