HTTP协议之天气预报信息获取接口API

xingyun86 2021-3-29 1636

近日无聊,分析了一个天气预报网站获取天气的一个HTTP请求接口,以供后续使用。

1.获取城市表(获取一次即可)

https://j.i8tq.com/weather2020/search/city.js

2.HTTP-GET请求

URL:(101280101为城市码,1616977490114为时间戳)

http://d1.weather.com.cn/weather_index/101280101.html?_=1616977490114

请求header:

User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0
Accept: */*
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
Referer: http://www.weather.com.cn/
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache

返回信息:

var cityDZ = {
    "weatherinfo": {
        "city": "101280101",
        "cityname": "广州",
        "temp": "31℃",
        "tempn": "22℃",
        "weather": "阴转多云",
        "wd": "南风转微风",
        "ws": "3-4级转<3级",
        "weathercode": "d2",
        "weathercoden": "n1",
        "fctime": "202103290800"
    }
};
var alarmDZ = {
    "w": []
};
var dataSK = {
    "nameen": "guangzhou",
    "cityname": "广州",
    "city": "101280101",
    "temp": "24",
    "tempf": "75",
    "WD": "南风",
    "wde": "S",
    "WS": "1级",
    "wse": "&lt;12km/h",
    "SD": "91%",
    "time": "07:50",
    "weather": "阴",
    "weathere": "Overcast",
    "weathercode": "d02",
    "qy": "1004",
    "njd": "暂缺",
    "sd": "91%",
    "rain": "0",
    "rain24h": "0",
    "aqi": "45",
    "limitnumber": "",
    "aqi_pm25": "45",
    "date": "03月29日(星期一)"
};
var dataZS = {
    "zs": {
        "date": "2021032908",
        "ac_name": "空调开启指数",
        "ac_hint": "部分时间开启",
        "ac_des_s": "午后天气炎热可适时开启制冷空调。",
        "ag_name": "过敏指数",
        "ag_hint": "易发",
        "ag_des_s": "应减少外出,外出需采取防护措施。",
        "cl_name": "晨练指数",
        "cl_hint": "较不宜",
        "cl_des_s": "室外锻炼请注意避免迎风锻炼。",
        "co_name": "舒适度指数",
        "co_hint": "较不舒适",
        "co_des_s": "多云到阴,湿度偏大,闷热。",
        "ct_name": "穿衣指数",
        "ct_hint": "炎热",
        "ct_des_s": "建议穿短衫、短裤等清凉夏季服装。",
        "dy_name": "钓鱼指数",
        "dy_hint": "不宜",
        "dy_des_s": "天气不好,有风,不适合垂钓。",
        "fs_name": "防晒指数",
        "fs_hint": "弱",
        "fs_des_s": "涂抹8-12SPF防晒护肤品。",
        "gj_name": "逛街指数",
        "gj_hint": "较适宜",
        "gj_des_s": "阴天稍热,逛街宜穿透气衣服。",
        "gl_name": "太阳镜指数",
        "gl_hint": "很必要",
        "gl_des_s": "建议佩戴透射比2级且UV400的浅色太阳镜",
        "gm_name": "感冒指数",
        "gm_hint": "少发",
        "gm_des_s": "感冒机率较低,避免长期处于空调屋中。",
        "gz_name": "干燥指数",
        "gz_hint": "适宜",
        "gz_des_s": "风速偏大,气温适宜,但体感温度会低一些,建议多使用保湿型护肤品涂抹皮肤,预防皮肤干燥。",
        "hc_name": "划船指数",
        "hc_hint": "较适宜",
        "hc_des_s": "风力较大可会对划船产生一定影响。",
        "jt_name": "交通指数",
        "jt_hint": "良好",
        "jt_des_s": "气象条件良好,车辆可以正常行驶。",
        "lk_name": "路况指数",
        "lk_hint": "干燥",
        "lk_des_s": "阴天,路面较干燥,路况较好。",
        "ls_name": "晾晒指数",
        "ls_hint": "不太适宜",
        "ls_des_s": "天气阴沉,请选择通风的地方晾晒。",
        "mf_name": "美发指数",
        "mf_hint": "一般",
        "mf_des_s": "天热,头皮皮脂分泌多,注意清洁。",
        "nl_name": "夜生活指数",
        "nl_hint": "较适宜",
        "nl_des_s": "只要您稍作准备就可以放心外出。",
        "pj_name": "啤酒指数",
        "pj_hint": "适宜",
        "pj_des_s": "天热潮湿,适宜饮用冰镇啤酒,不要贪杯。",
        "pk_name": "放风筝指数",
        "pk_hint": "不宜",
        "pk_des_s": "天气不好,不适宜放风筝。",
        "pl_name": "空气污染扩散条件指数",
        "pl_hint": "良",
        "pl_des_s": "气象条件有利于空气污染物扩散。",
        "pp_name": "化妆指数",
        "pp_hint": "去油",
        "pp_des_s": "请选用露质面霜打底,水质无油粉底霜。",
        "tr_name": "旅游指数",
        "tr_hint": "适宜",
        "tr_des_s": "风稍大,稍热,总体来说还是好天气。",
        "uv_name": "紫外线强度指数",
        "uv_hint": "最弱",
        "uv_des_s": "辐射弱,涂擦SPF8-12防晒护肤品。",
        "wc_name": "风寒指数",
        "wc_hint": "无",
        "wc_des_s": "温度未达到风寒所需的低温,稍作防寒准备即可。",
        "xc_name": "洗车指数",
        "xc_hint": "较不宜",
        "xc_des_s": "风力较大,洗车后会蒙上灰尘。",
        "xq_name": "心情指数",
        "xq_hint": "较差",
        "xq_des_s": "天气阴沉,会使人感觉郁闷烦躁。",
        "yd_name": "运动指数",
        "yd_hint": "较适宜",
        "yd_des_s": "请适当降低运动强度并注意户外防风。",
        "yh_name": "约会指数",
        "yh_hint": "较不适宜",
        "yh_des_s": "天气较热,建议尽量不要去室外约会。",
        "ys_name": "雨伞指数",
        "ys_hint": "不带伞",
        "ys_des_s": "阴天,无需带雨伞。",
        "zs_name": "中暑指数",
        "zs_hint": "无中暑风险",
        "zs_des_s": "天气不热,在炎炎夏日中十分难得,可以告别暑气漫漫啦~"
    },
    "cn": "广州"
};
var fc = {
    "f": [{
        "fa": "02",
        "fb": "01",
        "fc": "31",
        "fd": "22",
        "fe": "南风",
        "ff": "微风",
        "fg": "3-4级",
        "fh": "<3级",
        "fk": "4",
        "fl": "0",
        "fm": "94.3",
        "fn": "90.6",
        "fi": "3\/29",
        "fj": "今天"
    }, {
        "fa": "01",
        "fb": "02",
        "fc": "32",
        "fd": "23",
        "fe": "南风",
        "ff": "微风",
        "fg": "3-4级",
        "fh": "<3级",
        "fk": "4",
        "fl": "0",
        "fm": "91.2",
        "fn": "87.9",
        "fi": "3\/30",
        "fj": "周二"
    }, {
        "fa": "01",
        "fb": "02",
        "fc": "30",
        "fd": "24",
        "fe": "南风",
        "ff": "微风",
        "fg": "3-4级",
        "fh": "<3级",
        "fk": "4",
        "fl": "0",
        "fm": "92.5",
        "fn": "84.8",
        "fi": "3\/31",
        "fj": "周三"
    }, {
        "fa": "01",
        "fb": "01",
        "fc": "29",
        "fd": "24",
        "fe": "南风",
        "ff": "南风",
        "fg": "3-4级",
        "fh": "3-4级",
        "fk": "4",
        "fl": "4",
        "fm": "91.6",
        "fn": "90.7",
        "fi": "4\/1",
        "fj": "周四"
    }, {
        "fa": "01",
        "fb": "01",
        "fc": "31",
        "fd": "23",
        "fe": "东南风",
        "ff": "微风",
        "fg": "3-4级",
        "fh": "<3级",
        "fk": "3",
        "fl": "0",
        "fm": "92.0",
        "fn": "91.1",
        "fi": "4\/2",
        "fj": "周五"
    }]
}


上传的附件:
×
打赏作者
最新回复 (0)
只看楼主
全部楼主
返回