开源免费的天气预报接口API以及全国所有地区代码(国家气象局提供)
天气预报一直是各大网站的一个基本功能,最近小编也想在网站上弄一个,得瑟一下,在网络搜索了很久,终于找到了开源免费的天气预报接口API以及全国所有地区代码(国家气象局提供),具体如下:
国家气象局提供的天气预报接口
- http://www.weather.com.cn/data/sk/101010100.html
- http://www.weather.com.cn/data/cityinfo/101010100.html
- http://m.weather.com.cn/data/101010100.html
城市的编号
其中101010100表示每个城市的编号,编号代码获取获取地址
- 获取省级代码:http://www.weather.com.cn/data/list3/city.xml?level=1
- 获取城市代码(比如安徽是22):http://www.weather.com.cn/data/list3/city22.xml?level=2
- 获取区域代码(比如安庆是2206):http://www.weather.com.cn/data/list3/city2206.xml?level=3
获取到安徽省安庆市望江县的代码是220607 - 然后去加上中国代码请求URL:http://m.weather.com.cn/data/101220607.html 就可以获取当地天气。
图片接口
用过上面的api返回的数据中包含有图片名字可以通过一下地址访问
- http://m.weather.com.cn/img/c0.gif
- http://m.weather.com.cn/img/b0.gif
- http://www.weather.com.cn/m/i/weatherpic/29×20/d0.gif
- http: //www.weather.com.cn/m2/i/icon_weather/29×20/n00.gif
这个图就是天气现象0(晴)的 图片,其他天气现象的图片依此类推。c打头的图片是20*20像素的,b打头的是50*46像素的,d打头的是反白的图标,29*20像素,n打头的是夜 间反白图标,29*20像素,注意这里的文件名是两位数字!
解析数据
国家气象局提供的天气预报接口返回的是json数据,如果是php可以使用json_decode()转换为数组,遍历数组去除数据即可。
开源免费的天气预报接口API以及全国所有地区代码(国家气象局提供)的更多相关文章
- 开源免费天气预报接口API以及全国所有地区代码!!(国家气象局提供) 【转】
国家气象局提供的天气预报接口 接口地址: http://www.weather.com.cn/data/sk/101010100.html http://www.weather.com.cn/data ...
- 开源免费天气预报接口API以及全国全部地区代码!!(国家气象局提供)
国家气象局提供的天气预报接口 接口地址: http://www.weather.com.cn/data/sk/101010100.html http://www.weather.com.cn/data ...
- 开源免费天气预报接口API以及全国所有地区代码[值得收藏]
国家气象局提供的天气预报接口 接口地址: http://www.weather.com.cn/data/sk/101010100.html http://www.weather.com.cn/data ...
- (转)免费天气预报接口API以及全国所有地区代码!!
国家气象局提供的天气预报接口 接口地址: http://www.weather.com.cn/data/sk/101010100.html http://www.weather.com.cn/data ...
- 中国天气网-天气预报接口api
中国天气网地址:http://www.weather.com.cn 请求服务 : 查询实时天气信息 http://www.weather.com.cn/data/sk/101110101.html 在 ...
- 天气预报接口api(中国天气网)
中国天气weather.comhttp://m.weather.com.cn/data/101110101.html(六天预报) http://www.weather.com.cn/data/sk/1 ...
- ios 开源免费接口
ios 开源免费接口 国家气象局提供的天气预报接口 接口地址: http://www.weather.com.cn/data/sk/101010100.html http://www.weather. ...
- 基于JAVA的全国天气预报接口调用示例
step1:选择本文所示例的接口"全国天气预报接口" url:https://www.juhe.cn/docs/api/id/39/aid/87step2:每个接口都需要传入一个参 ...
- [Android] 免费天气预报接口
[Android] 免费天气预报接口 这是 国家气象局提供的天气预报接口 [免费] 当然,网上有很多的收费API或者每天定次数的接口 使用 国家气象局 的步骤如下: 1.首先获取城市ID号 北京:10 ...
随机推荐
- LintCode Interleaving String
Given three strings: s1, s2, s3, determine whether s3 is formed by the interleaving of s1 and s2. Ex ...
- python 使用virtualenvrapper虚拟环境管理工具
centos 默认安装的python是2.6版本的 使用virtualenv 环境管理工具建立python虚拟环境的时候会遇到一些错误,DEPRECATION: Python 2.6 is no lo ...
- java 队列基础操作
http://www.cnblogs.com/fuck1/p/5996116.html 队列(简称作队,Queue)也是一种特殊的线性表,队列的数据元素以及数据元素间的逻辑关系和线性表完全相同,其差别 ...
- Binary Tree Postorder Traversal
Given a binary tree, return the postorder traversal of its nodes' values. For example:Given binary t ...
- 关于as3调用js报“null为空或不是对象”错误
主要原因是:flash插件的object对象无ID属性. 顺便说下as3调用js的方法. as3引用: import flash.external.ExternalInterface; as3中调用 ...
- 关于JS的总结
=============================================事件:(事件必须小写) 用户的操作 onclick onmouseover onmouseout======= ...
- job history 的查看
linux shell 可以启动 mapred historyserver 然后根据显示的端口hostname+port进行访问(一般默认端口是19888)
- error LNK2019: 无法解析的外部符号 _WinMain@16,该符号在函数 ___tmainCRTStartup 中被引用
MSVCRTD.lib(crtexew.obj) : error LNK2019: 无法解析的外部符号 _WinMain@16,该符号在函数 ___tmainCRTStartup 中被引用 Debug ...
- Codeforces Round #341 Div.2 C. Wet Shark and Flowers
题意: 不概括了..太长了.. 额第一次做这种问题 算是概率dp吗? 保存前缀项中第一个和最后一个的概率 然后每添加新的一项 就解除前缀和第一项和最后一项的关系 并添加新的一项和保存的两项的关系 这里 ...
- C#参数化执行SQL语句,防止漏洞攻击本文以MySql为例【20151108非查询操作】
为什么要参数化执行SQL语句呢? 一个作用就是可以防止用户注入漏洞. 简单举个列子吧. 比如账号密码登入,如果不用参数, 写的简单点吧,就写从数据库查找到id和pw与用户输入一样的数据吧 sql:se ...