zoukankan      html  css  js  c++  java
  • 天气预报API(六):中国气象频道、腾讯天气--“新编码”接口的测试

    说明

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


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

    腾讯天气

    空气质量指数 (aqi)

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

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



    1. "pm2_5": 0
    2. "primary_pollutant": null
    3. "co": 0.3
    4. "pm10": 0
    5. "area": "青岛"
    6. "o3_8h": 82
    7. "o3": 83
    8. "o3_24h": 92
    9. "station_code": "1307A"
    10. "quality": "优"
    11. "co_24h": 0.4
    12. "no2_24h": 5
    13. "so2": 36
    14. "so2_24h": 37
    15. "time_point": "2016-12-10T22:00:00Z"
    16. "pm2_5_24h": 0
    17. "position_name": "仰口"
    18. "o3_8h_24h": 87
    19. "aqi": 26
    20. "pm10_24h": 0
    21. "no2": 4 
    22. }, 

    23. "pm2_5": 54
    24. "primary_pollutant": "细颗粒物(PM2.5)"
    25. "co": 1.1
    26. "pm10": 89
    27. "area": "青岛"
    28. "o3_8h": 20
    29. "o3": 4
    30. "o3_24h": 61
    31. "station_code": "1308A"
    32. "quality": "良"
    33. "co_24h": 0.6
    34. "no2_24h": 52
    35. "so2": 61
    36. "so2_24h": 27
    37. "time_point": "2016-12-10T22:00:00Z"
    38. "pm2_5_24h": 33
    39. "position_name": "李沧区子站"
    40. "o3_8h_24h": 61
    41. "aqi": 74
    42. "pm10_24h": 60
    43. "no2": 88 
    44. }, 

    45. "pm2_5": 40
    46. "primary_pollutant": "细颗粒物(PM2.5)"
    47. "co": 0.8
    48. "pm10": 0
    49. "area": "青岛"
    50. "o3_8h": 33
    51. "o3": 12
    52. "o3_24h": 63
    53. "station_code": "1309A"
    54. "quality": "良"
    55. "co_24h": 0.5
    56. "no2_24h": 33
    57. "so2": 25
    58. "so2_24h": 30
    59. "time_point": "2016-12-10T22:00:00Z"
    60. "pm2_5_24h": 27
    61. "position_name": "市北区子站"
    62. "o3_8h_24h": 61
    63. "aqi": 57
    64. "pm10_24h": 66
    65. "no2": 48 
    66. }, 

    67. "pm2_5": 13
    68. "primary_pollutant": "颗粒物(PM10)"
    69. "co": 0.5
    70. "pm10": 67
    71. "area": "青岛"
    72. "o3_8h": 22
    73. "o3": 12
    74. "o3_24h": 51
    75. "station_code": "1310A"
    76. "quality": "良"
    77. "co_24h": 0.4
    78. "no2_24h": 57
    79. "so2": 11
    80. "so2_24h": 9
    81. "time_point": "2016-12-10T22:00:00Z"
    82. "pm2_5_24h": 12
    83. "position_name": "市南区东部子站"
    84. "o3_8h_24h": 43
    85. "aqi": 59
    86. "pm10_24h": 59
    87. "no2": 89 
    88. }, 

    89. "pm2_5": 45
    90. "primary_pollutant": "细颗粒物(PM2.5)"
    91. "co": 1.3
    92. "pm10": 59
    93. "area": "青岛"
    94. "o3_8h": 34
    95. "o3": 13
    96. "o3_24h": 68
    97. "station_code": "1311A"
    98. "quality": "良"
    99. "co_24h": 1
    100. "no2_24h": 50
    101. "so2": 23
    102. "so2_24h": 25
    103. "time_point": "2016-12-10T22:00:00Z"
    104. "pm2_5_24h": 29
    105. "position_name": "四方区子站"
    106. "o3_8h_24h": 68
    107. "aqi": 63
    108. "pm10_24h": 57
    109. "no2": 77 
    110. }, 

    111. "pm2_5": 30
    112. "primary_pollutant": "颗粒物(PM10)"
    113. "co": 0.8
    114. "pm10": 61
    115. "area": "青岛"
    116. "o3_8h": 41
    117. "o3": 18
    118. "o3_24h": 62
    119. "station_code": "1312A"
    120. "quality": "良"
    121. "co_24h": 0.6
    122. "no2_24h": 45
    123. "so2": 26
    124. "so2_24h": 25
    125. "time_point": "2016-12-10T22:00:00Z"
    126. "pm2_5_24h": 23
    127. "position_name": "市南区西部子站"
    128. "o3_8h_24h": 56
    129. "aqi": 56
    130. "pm10_24h": 55
    131. "no2": 77 
    132. }, 

    133. "pm2_5": 37
    134. "primary_pollutant": "颗粒物(PM10)"
    135. "co": 0.7
    136. "pm10": 60
    137. "area": "青岛"
    138. "o3_8h": 38
    139. "o3": 20
    140. "o3_24h": 58
    141. "station_code": "1313A"
    142. "quality": "良"
    143. "co_24h": 0.5
    144. "no2_24h": 33
    145. "so2": 37
    146. "so2_24h": 26
    147. "time_point": "2016-12-10T22:00:00Z"
    148. "pm2_5_24h": 20
    149. "position_name": "崂山区子站"
    150. "o3_8h_24h": 52
    151. "aqi": 55
    152. "pm10_24h": 35
    153. "no2": 65 
    154. }, 

    155. "pm2_5": 42
    156. "primary_pollutant": "颗粒物(PM10)"
    157. "co": 0.6
    158. "pm10": 122
    159. "area": "青岛"
    160. "o3_8h": 97
    161. "o3": 93
    162. "o3_24h": 106
    163. "station_code": "1314A"
    164. "quality": "良"
    165. "co_24h": 0.5
    166. "no2_24h": 60
    167. "so2": 32
    168. "so2_24h": 31
    169. "time_point": "2016-12-10T22:00:00Z"
    170. "pm2_5_24h": 32
    171. "position_name": "黄岛区子站"
    172. "o3_8h_24h": 100
    173. "aqi": 86
    174. "pm10_24h": 85
    175. "no2": 79 
    176. }, 

    177. "pm2_5": 65
    178. "primary_pollutant": "颗粒物(PM10)"
    179. "co": 2.1
    180. "pm10": 146
    181. "area": "青岛"
    182. "o3_8h": 41
    183. "o3": 13
    184. "o3_24h": 79
    185. "station_code": "1315A"
    186. "quality": "良"
    187. "co_24h": 1
    188. "no2_24h": 37
    189. "so2": 56
    190. "so2_24h": 38
    191. "time_point": "2016-12-10T22:00:00Z"
    192. "pm2_5_24h": 34
    193. "position_name": "城阳区子站"
    194. "o3_8h_24h": 67
    195. "aqi": 98
    196. "pm10_24h": 66
    197. "no2": 71 
    198. }, 

    199. "pm2_5": 40
    200. "primary_pollutant": "颗粒物(PM10)"
    201. "co": 0.911
    202. "pm10": 86
    203. "area": "青岛"
    204. "o3_8h": 45
    205. "o3": 29
    206. "o3_24h": 71
    207. "station_code": null
    208. "quality": "良"
    209. "co_24h": 0.611
    210. "no2_24h": 41
    211. "so2": 34
    212. "so2_24h": 27
    213. "time_point": "2016-12-10T22:00:00Z"
    214. "pm2_5_24h": 26
    215. "position_name": null
    216. "o3_8h_24h": 66
    217. "aqi": 69
    218. "pm10_24h": 60
    219. "no2": 66 


    城市AQI 排名

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

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

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

    aqi rank

    城市基本天气信息

    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. "weather": "00"
    2. "weatherDecoder": "晴"
    3. "weatherPic": "images/weatherPng/n00.png"
    4. "temperature": "3.1"
    5. "feelTemperature": "3"
    6. "windDir": "1"
    7. "windDirDecoder": "东北风"
    8. "windPower": "0"
    9. "windPowerDecoder": "微风"
    10. "windDirAngle": "56"
    11. "windSpeed": "1"
    12. "humidity": "52.0"
    13. "pressure": "1030.1"
    14. "visibility": "18"
    15. "sunrise": "06:56"
    16. "sunset": "16:45"
    17. "lunar": "12/11 冬月十三 周日"
    18. "solarTerm": "大雪"
    19. "publicTime": "23"
    20. "threeTimea": "今日2时"
    21. "threeWeatherPica": "images/weatherPng/n01.png"
    22. "threeWeatherDecodera": "多云"
    23. "threeWeathera": "3.7"
    24. "threeTimeb": "今日5时"
    25. "threeWeatherPicb": "images/weatherPng/n01.png"
    26. "threeWeatherDecoderb": "多云"
    27. "threeWeatherb": "4.4"
    28. "threeTimec": "今日8时"
    29. "threeWeatherPicc": "images/weatherPng/d02.png"
    30. "threeWeatherDecoderc": "阴"
    31. "threeWeatherc": "7.8"
    32. "threeTimed": "今日11时"
    33. "threeWeatherPicd": "images/weatherPng/d02.png"
    34. "threeWeatherDecoderd": "阴"
    35. "threeWeatherd": "9.3"
    36. "beans":[]
    37. "tmax": "6"
    38. "tmin": "2" 

    结束语

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

  • 相关阅读:
    力扣338. 比特位计数
    力扣22. 括号生成
    力扣46. 全排列
    力扣461. 汉明距离
    力扣617. 合并二叉树
    zabbix环境搭建部署(一)
    cacti,zabbix,nagios各自原理及区别
    两个硬盘对拷图解
    自动化运维之SaltStack实践
    nginx配置ssl证书
  • 原文地址:https://www.cnblogs.com/oucbl/p/6158727.html
Copyright © 2011-2022 走看看