标签:cat number xmlhttp javascrip 腾讯 山东省 发布 name 参数
本文所有测试均以青岛为例。
本文所列接口城市代码(cityid)参数都使用的 “新编码”:
全国城市代码列表(新)
本文接口均不是官方接口,仅供测试使用!
http://weather.gtimg.cn/aqi/01012310.json?callback=
返回unicode字符编码,并且数值是浮点数;
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
这里只是提供个入口,是一定有办法获取能看到所有信息的。
具体方法我就不给出了,可以和我交流讨论。
天气预报API(六):中国气象频道、腾讯天气--“新编码”接口的测试
标签:cat number xmlhttp javascrip 腾讯 山东省 发布 name 参数
原文地址:http://www.cnblogs.com/oucbl/p/6158727.html