天气预报API(六):中国气象频道、腾讯天气--“新编码”接口的测试

时间:2016-12-11 02:04:24   收藏:0   阅读:915

说明

本文所有测试均以青岛为例。
本文所列接口城市代码(cityid)参数都使用的 “新编码”:
全国城市代码列表(新)


本文接口均不是官方接口,仅供测试使用!

腾讯天气

空气质量指数 (aqi)

http://weather.gtimg.cn/aqi/01012310.json?callback=

返回unicode字符编码,并且数值是浮点数;

  1. [ 
  2. { 
  3. "pm2_5": 0, 
  4. "primary_pollutant": null, 
  5. "co": 0.3, 
  6. "pm10": 0, 
  7. "area": "青岛", 
  8. "o3_8h": 82, 
  9. "o3": 83, 
  10. "o3_24h": 92, 
  11. "station_code": "1307A", 
  12. "quality": "优", 
  13. "co_24h": 0.4, 
  14. "no2_24h": 5, 
  15. "so2": 36, 
  16. "so2_24h": 37, 
  17. "time_point": "2016-12-10T22:00:00Z", 
  18. "pm2_5_24h": 0, 
  19. "position_name": "仰口", 
  20. "o3_8h_24h": 87, 
  21. "aqi": 26, 
  22. "pm10_24h": 0, 
  23. "no2": 4 
  24. }, 
  25. { 
  26. "pm2_5": 54, 
  27. "primary_pollutant": "细颗粒物(PM2.5)", 
  28. "co": 1.1, 
  29. "pm10": 89, 
  30. "area": "青岛", 
  31. "o3_8h": 20, 
  32. "o3": 4, 
  33. "o3_24h": 61, 
  34. "station_code": "1308A", 
  35. "quality": "良", 
  36. "co_24h": 0.6, 
  37. "no2_24h": 52, 
  38. "so2": 61, 
  39. "so2_24h": 27, 
  40. "time_point": "2016-12-10T22:00:00Z", 
  41. "pm2_5_24h": 33, 
  42. "position_name": "李沧区子站", 
  43. "o3_8h_24h": 61, 
  44. "aqi": 74, 
  45. "pm10_24h": 60, 
  46. "no2": 88 
  47. }, 
  48. { 
  49. "pm2_5": 40, 
  50. "primary_pollutant": "细颗粒物(PM2.5)", 
  51. "co": 0.8, 
  52. "pm10": 0, 
  53. "area": "青岛", 
  54. "o3_8h": 33, 
  55. "o3": 12, 
  56. "o3_24h": 63, 
  57. "station_code": "1309A", 
  58. "quality": "良", 
  59. "co_24h": 0.5, 
  60. "no2_24h": 33, 
  61. "so2": 25, 
  62. "so2_24h": 30, 
  63. "time_point": "2016-12-10T22:00:00Z", 
  64. "pm2_5_24h": 27, 
  65. "position_name": "市北区子站", 
  66. "o3_8h_24h": 61, 
  67. "aqi": 57, 
  68. "pm10_24h": 66, 
  69. "no2": 48 
  70. }, 
  71. { 
  72. "pm2_5": 13, 
  73. "primary_pollutant": "颗粒物(PM10)", 
  74. "co": 0.5, 
  75. "pm10": 67, 
  76. "area": "青岛", 
  77. "o3_8h": 22, 
  78. "o3": 12, 
  79. "o3_24h": 51, 
  80. "station_code": "1310A", 
  81. "quality": "良", 
  82. "co_24h": 0.4, 
  83. "no2_24h": 57, 
  84. "so2": 11, 
  85. "so2_24h": 9, 
  86. "time_point": "2016-12-10T22:00:00Z", 
  87. "pm2_5_24h": 12, 
  88. "position_name": "市南区东部子站", 
  89. "o3_8h_24h": 43, 
  90. "aqi": 59, 
  91. "pm10_24h": 59, 
  92. "no2": 89 
  93. }, 
  94. { 
  95. "pm2_5": 45, 
  96. "primary_pollutant": "细颗粒物(PM2.5)", 
  97. "co": 1.3, 
  98. "pm10": 59, 
  99. "area": "青岛", 
  100. "o3_8h": 34, 
  101. "o3": 13, 
  102. "o3_24h": 68, 
  103. "station_code": "1311A", 
  104. "quality": "良", 
  105. "co_24h": 1, 
  106. "no2_24h": 50, 
  107. "so2": 23, 
  108. "so2_24h": 25, 
  109. "time_point": "2016-12-10T22:00:00Z", 
  110. "pm2_5_24h": 29, 
  111. "position_name": "四方区子站", 
  112. "o3_8h_24h": 68, 
  113. "aqi": 63, 
  114. "pm10_24h": 57, 
  115. "no2": 77 
  116. }, 
  117. { 
  118. "pm2_5": 30, 
  119. "primary_pollutant": "颗粒物(PM10)", 
  120. "co": 0.8, 
  121. "pm10": 61, 
  122. "area": "青岛", 
  123. "o3_8h": 41, 
  124. "o3": 18, 
  125. "o3_24h": 62, 
  126. "station_code": "1312A", 
  127. "quality": "良", 
  128. "co_24h": 0.6, 
  129. "no2_24h": 45, 
  130. "so2": 26, 
  131. "so2_24h": 25, 
  132. "time_point": "2016-12-10T22:00:00Z", 
  133. "pm2_5_24h": 23, 
  134. "position_name": "市南区西部子站", 
  135. "o3_8h_24h": 56, 
  136. "aqi": 56, 
  137. "pm10_24h": 55, 
  138. "no2": 77 
  139. }, 
  140. { 
  141. "pm2_5": 37, 
  142. "primary_pollutant": "颗粒物(PM10)", 
  143. "co": 0.7, 
  144. "pm10": 60, 
  145. "area": "青岛", 
  146. "o3_8h": 38, 
  147. "o3": 20, 
  148. "o3_24h": 58, 
  149. "station_code": "1313A", 
  150. "quality": "良", 
  151. "co_24h": 0.5, 
  152. "no2_24h": 33, 
  153. "so2": 37, 
  154. "so2_24h": 26, 
  155. "time_point": "2016-12-10T22:00:00Z", 
  156. "pm2_5_24h": 20, 
  157. "position_name": "崂山区子站", 
  158. "o3_8h_24h": 52, 
  159. "aqi": 55, 
  160. "pm10_24h": 35, 
  161. "no2": 65 
  162. }, 
  163. { 
  164. "pm2_5": 42, 
  165. "primary_pollutant": "颗粒物(PM10)", 
  166. "co": 0.6, 
  167. "pm10": 122, 
  168. "area": "青岛", 
  169. "o3_8h": 97, 
  170. "o3": 93, 
  171. "o3_24h": 106, 
  172. "station_code": "1314A", 
  173. "quality": "良", 
  174. "co_24h": 0.5, 
  175. "no2_24h": 60, 
  176. "so2": 32, 
  177. "so2_24h": 31, 
  178. "time_point": "2016-12-10T22:00:00Z", 
  179. "pm2_5_24h": 32, 
  180. "position_name": "黄岛区子站", 
  181. "o3_8h_24h": 100, 
  182. "aqi": 86, 
  183. "pm10_24h": 85, 
  184. "no2": 79 
  185. }, 
  186. { 
  187. "pm2_5": 65, 
  188. "primary_pollutant": "颗粒物(PM10)", 
  189. "co": 2.1, 
  190. "pm10": 146, 
  191. "area": "青岛", 
  192. "o3_8h": 41, 
  193. "o3": 13, 
  194. "o3_24h": 79, 
  195. "station_code": "1315A", 
  196. "quality": "良", 
  197. "co_24h": 1, 
  198. "no2_24h": 37, 
  199. "so2": 56, 
  200. "so2_24h": 38, 
  201. "time_point": "2016-12-10T22:00:00Z", 
  202. "pm2_5_24h": 34, 
  203. "position_name": "城阳区子站", 
  204. "o3_8h_24h": 67, 
  205. "aqi": 98, 
  206. "pm10_24h": 66, 
  207. "no2": 71 
  208. }, 
  209. { 
  210. "pm2_5": 40, 
  211. "primary_pollutant": "颗粒物(PM10)", 
  212. "co": 0.911, 
  213. "pm10": 86, 
  214. "area": "青岛", 
  215. "o3_8h": 45, 
  216. "o3": 29, 
  217. "o3_24h": 71, 
  218. "station_code": null, 
  219. "quality": "良", 
  220. "co_24h": 0.611, 
  221. "no2_24h": 41, 
  222. "so2": 34, 
  223. "so2_24h": 27, 
  224. "time_point": "2016-12-10T22:00:00Z", 
  225. "pm2_5_24h": 26, 
  226. "position_name": null, 
  227. "o3_8h_24h": 66, 
  228. "aqi": 69, 
  229. "pm10_24h": 60, 
  230. "no2": 66 
  231. } 
  232. ] 

城市AQI 排名

http://weather.gtimg.cn/aqi/cityrank.json?callback=cityrank

返回unicode字符编码,并且数值是浮点数;

返回json array 类型,这里只是截图显示下结构:

技术分享

城市基本天气信息

http://weather.gtimg.cn/city/01012310.js

这个js文件不是纯json格式,需要处理一下才能使用

var __weather_city = {"bi_name": "青岛", "zs_xc": "2", "h3": {"rt": "2016-12-10 20:00:00", "0": [{"wd": "4", "ts": "2016-12-10 23:00:00", "tp": "2", "wkd": "6", "wt": "00", "wp": "0", "te": "2016-12-11 2:00:00"}, {"wd": "4", "ts": "2016-12-11 2:00:00", "tp": "2", "wkd": "7", "wt": "00", "wp": "0", "te": "2016-12-11 5:00:00"}, {"wd": "4", "ts": "2016-12-11 5:00:00", "tp": "2", "wkd": "7", "wt": "00", "wp": "0", "te": "2016-12-11 8:00:00"}, {"wd": "4", "ts": "2016-12-11 8:00:00", "tp": "3", "wkd": "7", "wt": "00", "wp": "0", "te": "2016-12-11 11:00:00"}, {"wd": "4", "ts": "2016-12-11 11:00:00", "tp": "7", "wkd": "7", "wt": "00", "wp": "0", "te": "2016-12-11 14:00:00"}, {"wd": "4", "ts": "2016-12-11 14:00:00", "tp": "8", "wkd": "7", "wt": "00", "wp": "0", "te": "2016-12-11 17:00:00"}, {"wd": "4", "ts": "2016-12-11 17:00:00", "tp": "7", "wkd": "7", "wt": "00", "wp": "0", "te": "2016-12-11 20:00:00"}, {"wd": "4", "ts": "2016-12-11 20:00:00", "tp": "8", "wkd": "7", "wt": "00", "wp": "1", "te": "2016-12-11 23:00:00"}, {"wd": "4", "ts": "2016-12-11 23:00:00", "tp": "8", "wkd": "7", "wt": "00", "wp": "1", "te": "2016-12-12 2:00:00"}, {"wd": "4", "ts": "2016-12-12 2:00:00", "tp": "8", "wkd": "1", "wt": "00", "wp": "0", "te": "2016-12-12 5:00:00"}, {"wd": "4", "ts": "2016-12-12 5:00:00", "tp": "9", "wkd": "1", "wt": "00", "wp": "0", "te": "2016-12-12 8:00:00"}, {"wd": "4", "ts": "2016-12-12 8:00:00", "tp": "9", "wkd": "1", "wt": "00", "wp": "0", "te": "2016-12-12 11:00:00"}, {"wd": "8", "ts": "2016-12-12 11:00:00", "tp": "10", "wkd": "1", "wt": "02", "wp": "1", "te": "2016-12-12 14:00:00"}, {"wd": "8", "ts": "2016-12-12 14:00:00", "tp": "10", "wkd": "1", "wt": "03", "wp": "0", "te": "2016-12-12 17:00:00"}, {"wd": "8", "ts": "2016-12-12 17:00:00", "tp": "9", "wkd": "1", "wt": "03", "wp": "0", "te": "2016-12-12 20:00:00"}, {"wd": "8", "ts": "2016-12-12 20:00:00", "tp": "8", "wkd": "1", "wt": "03", "wp": "0", "te": "2016-12-12 23:00:00"}]}, "zs_cy": "7", "zs_rt": "2016-12-10 8:00:00", "zs_zs": "0", "zs_kqwr": "2", "zs_gj": "1", "zs_xq": "2", "zs_gm": "1", "zs_pj": "1", "zs_cl": "3", "zs_ysh": "2", "sk_vb": "NULL", "zs_lk": "1", "zs_kt": "5", "sk_ws": "1.4", "bi_sid": "54857", "zs_dy": "2", "sk_ps": "1022", "sk_tp": "3", "zs_mf": "2", "bi_cid": "01012310", "zs_yd": "3", "sk_wda": "98", "news_txt": [{"rt": "2014-5-11 9:30:00", "ac": "青岛市气象台2014年05月11日09时30分发布大雾黄色预警信号:目前我市沿海地区已出现能见度小于500米的大雾,预计今天白天雾仍将持续,请注意防范。", "pv": "山东省", "url": "http://3g.mywtv.cn", "uv": "http://mobile.mywtv.cn/video20/zhaowen3_android.3gp", "al": "黄色", "cny": "", "at": "大雾", "ulc": "更多预警信息点击...", "rlt": "", "ds": "青岛市"}], "wk": {"rt": "2016-12-10 20:00:00", "0": [{"wd": "4", "tmin": "2", "tmax": "NULL", "wkd": "6", "ts": "2016-12-10 20:00:00", "wt": "00", "wp": "1", "te": "2016-12-11 8:00:00"}, {"wd": "4", "tmin": "NULL", "tmax": "9", "wkd": "6", "ts": "2016-12-11 8:00:00", "wt": "00", "wp": "1", "te": "2016-12-11 20:00:00"}, {"wd": "4", "tmin": "7", "tmax": "NULL", "wkd": "7", "ts": "2016-12-11 20:00:00", "wt": "00", "wp": "1", "te": "2016-12-12 8:00:00"}, {"wd": "8", "tmin": "NULL", "tmax": "11", "wkd": "7", "ts": "2016-12-12 8:00:00", "wt": "00", "wp": "1", "te": "2016-12-12 20:00:00"}, {"wd": "8", "tmin": "4", "tmax": "NULL", "wkd": "1", "ts": "2016-12-12 20:00:00", "wt": "03", "wp": "1", "te": "2016-12-13 8:00:00"}, {"wd": "8", "tmin": "NULL", "tmax": "5", "wkd": "1", "ts": "2016-12-13 8:00:00", "wt": "03", "wp": "3", "te": "2016-12-13 20:00:00"}, {"wd": "8", "tmin": "-2", "tmax": "NULL", "wkd": "2", "ts": "2016-12-13 20:00:00", "wt": "00", "wp": "3", "te": "2016-12-14 8:00:00"}, {"wd": "8", "tmin": "NULL", "tmax": "2", "wkd": "2", "ts": "2016-12-14 8:00:00", "wt": "00", "wp": "2", "te": "2016-12-14 20:00:00"}, {"wd": "8", "tmin": "-2", "tmax": "NULL", "wkd": "3", "ts": "2016-12-14 20:00:00", "wt": "00", "wp": "2", "te": "2016-12-15 8:00:00"}, {"wd": "8", "tmin": "NULL", "tmax": "4", "wkd": "3", "ts": "2016-12-15 8:00:00", "wt": "00", "wp": "2", "te": "2016-12-15 20:00:00"}, {"wd": "8", "tmin": "-1", "tmax": "NULL", "wkd": "4", "ts": "2016-12-15 20:00:00", "wt": "00", "wp": "2", "te": "2016-12-16 8:00:00"}, {"wd": "4", "tmin": "NULL", "tmax": "5", "wkd": "4", "ts": "2016-12-16 8:00:00", "wt": "00", "wp": "2", "te": "2016-12-16 20:00:00"}, {"wd": "4", "tmin": "1", "tmax": "NULL", "wkd": "5", "ts": "2016-12-16 20:00:00", "wt": "00", "wp": "2", "te": "2016-12-17 8:00:00"}, {"wd": "4", "tmin": "NULL", "tmax": "8", "wkd": "5", "ts": "2016-12-17 8:00:00", "wt": "00", "wp": "2", "te": "2016-12-17 20:00:00"}]}, "sk_rt": "2016-12-10 23:50:00", "zs_fs": "3", "zs_yh": "2", "zs_zwx": "3", "sk_hd": "54", "zs_ys": "1", "zs_fh": "8", "bi_sr": "06:59", "bi_ss": "16:44", "bi_lat": "36.088", "zs_ly": "3", "zs_te": "2016-12-11 8:00:00", "sk_wd": "2", "bi_long": "120.343", "zs_ffz": "3", "zs_ls": "3", "zs_jt": "1", "zs_hz": "1", "sk_wp": "1", "zs_ts": "2016-12-10 8:00:00", "zs_ssd": "1", "sk_wt": "01", "zs_hc": "2"};

中国气象频道

城市天气信息

重要的是Cookie里面的参数

GET /getSkData.do;jsessionid=D83B3F61E769A31DD5141C5BBB267AC8?cityCode=01012310 HTTP/1.1
Host: 3g.tianqi.cn
Accept: application/json, text/javascript, */*; q=0.01
Accept-Encoding: gzip, deflate, sdch
Accept-Language: zh-CN,zh;q=0.8
Cookie: Hm_lvt_ce10d82ee6d6df088908bc379b31906d=1481369909; Hm_lpvt_ce10d82ee6d6df088908bc379b31906d=1481387987; cityCode=01012310; cityName=%E9%9D%92%E5%B2%9B
Proxy-Connection: keep-alive
Referer: http://3g.tianqi.cn/index.html
User-Agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 920)
X-Requested-With: XMLHttpRequest
  1. { 
  2. "weather": "00", 
  3. "weatherDecoder": "晴", 
  4. "weatherPic": "images/weatherPng/n00.png", 
  5. "temperature": "3.1", 
  6. "feelTemperature": "3", 
  7. "windDir": "1", 
  8. "windDirDecoder": "东北风", 
  9. "windPower": "0", 
  10. "windPowerDecoder": "微风", 
  11. "windDirAngle": "56", 
  12. "windSpeed": "1", 
  13. "humidity": "52.0", 
  14. "pressure": "1030.1", 
  15. "visibility": "18", 
  16. "sunrise": "06:56", 
  17. "sunset": "16:45", 
  18. "lunar": "12/11 冬月十三 周日", 
  19. "solarTerm": "大雪", 
  20. "publicTime": "23", 
  21. "threeTimea": "今日2时", 
  22. "threeWeatherPica": "images/weatherPng/n01.png", 
  23. "threeWeatherDecodera": "多云", 
  24. "threeWeathera": "3.7", 
  25. "threeTimeb": "今日5时", 
  26. "threeWeatherPicb": "images/weatherPng/n01.png", 
  27. "threeWeatherDecoderb": "多云", 
  28. "threeWeatherb": "4.4", 
  29. "threeTimec": "今日8时", 
  30. "threeWeatherPicc": "images/weatherPng/d02.png", 
  31. "threeWeatherDecoderc": "阴", 
  32. "threeWeatherc": "7.8", 
  33. "threeTimed": "今日11时", 
  34. "threeWeatherPicd": "images/weatherPng/d02.png", 
  35. "threeWeatherDecoderd": "阴", 
  36. "threeWeatherd": "9.3", 
  37. "beans":[], 
  38. "tmax": "6", 
  39. "tmin": "2" 
  40. } 

结束语

这里只是提供个入口,是一定有办法获取能看到所有信息的。
具体方法我就不给出了,可以和我交流讨论。

评论(0)
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!