首页 > 其他分享 >moji

moji

时间:2024-11-15 22:08:07浏览次数:1  
标签:humidity aqiDesc aqiLevel weather realFeel moji aqiValue

h5ctywhr.api.moji.com/fc40

https://h5ctywhr.api.moji.com/weatherDetail

{"cityId":"280000","cityType":0}: 

 

/*城市搜索*/
var searchBaseUrl = "https://ssch.api.moji.com/citymanage/json/h5/searchCity";

'keyWord': cityName

/**城市列表 */
var cityListBase = "https://h5ctywhr.api.moji.com/weatherthird/cityList";
/**省对应城市id接口 */
var mapCityBase = "https://h5ctywhr.api.moji.com/weatherthird/provincialList";
/**预警列表接口 */
var alertBase = "https://h5ctywhr.api.moji.com/weatherthird/alertPage";
/**首页预警接口*/
var alertIndexBase = "https://h5ctywhr.api.moji.com/weatherthird/alert";

{"aqi":{"desc":"优","level":1,"value":16},"cityId":280000,"cityName":"深圳市龙华区","code":0,"condition":{"humidity":94,"icon":31,"mslp":0,"pressure":0,"realFeel":26,"temp":23,"tips":"","updateTime":1731675249,"weather":"多云","weatherId":82,"windDir":"北风","windLevel":2,"wspd":2.31},"countryName":"中国","forecastDays":{"forecastDay":[{"aqiDesc":"优","aqiLevel":1,"aqiValue":16,"festival":"","humidity":89,"iconDay":3,"iconNight":33,"predictDate":1731513600,"realFeel":0,"sunDown":1731577200,"sunRise":1731537360,"tempHigh":26,"tempLow":23,"weatherDay":"阵雨","weatherNight":"阵雨","weatherType":0,"windDirDay":"东北风","windDirNight":"东北风","windLevelDay":"3","windLevelNight":"2","wspdDay":4.4,"wspdNight":2.4},{"aqiDesc":"优","aqiLevel":1,"aqiValue":19,"festival":"","humidity":85,"iconDay":8,"iconNight":33,"predictDate":1731600000,"realFeel":0,"sunDown":1731663600,"sunRise":1731623820,"tempHigh":27,"tempLow":23,"weatherDay":"中雨","weatherNight":"阵雨","weatherType":2,"windDirDay":"东北风","windDirNight":"东北风","windLevelDay":"1","windLevelNight":"1","wspdDay":0.9,"wspdNight":0.9},{"aqiDesc":"优","aqiLevel":1,"aqiValue":37,"festival":"","humidity":79,"iconDay":1,"iconNight":31,"predictDate":1731686400,"realFeel":0,"sunDown":1731750000,"sunRise":1731710280,"tempHigh":30,"tempLow":23,"weatherDay":"多云","weatherNight":"多云","weatherType":0,"windDirDay":"西北风","windDirNight":"东北风","windLevelDay":"2","windLevelNight":"2","wspdDay":2.4,"wspdNight":2.4},{"aqiDesc":"优","aqiLevel":1,"aqiValue":43,"festival":"","humidity":74,"iconDay":3,"iconNight":31,"predictDate":1731772800,"realFeel":0,"sunDown":1731836340,"sunRise":1731796680,"tempHigh":28,"tempLow":22,"weatherDay":"阵雨","weatherNight":"多云","weatherType":2,"windDirDay":"东北风","windDirNight":"东北风","windLevelDay":"2","windLevelNight":"2","wspdDay":2.4,"wspdNight":2.4},{"aqiDesc":"优","aqiLevel":1,"aqiValue":36,"festival":"","humidity":64,"iconDay":1,"iconNight":33,"predictDate":1731859200,"realFeel":0,"sunDown":1731922740,"sunRise":1731883140,"tempHigh":27,"tempLow":19,"weatherDay":"多云","weatherNight":"阵雨","weatherType":2,"windDirDay":"东北风","windDirNight":"东北风","windLevelDay":"2","windLevelNight":"2","wspdDay":2.4,"wspdNight":2.4},{"aqiDesc":"优","aqiLevel":1,"aqiValue":34,"festival":"","humidity":62,"iconDay":1,"iconNight":7,"predictDate":1731945600,"realFeel":0,"sunDown":1732009140,"sunRise":1731969600,"tempHigh":22,"tempLow":18,"weatherDay":"多云","weatherNight":"小雨","weatherType":2,"windDirDay":"东北风","windDirNight":"东北风","windLevelDay":"3","windLevelNight":"2","wspdDay":4.4,"wspdNight":2.4},{"aqiDesc":"优","aqiLevel":1,"aqiValue":28,"festival":"","humidity":65,"iconDay":7,"iconNight":7,"predictDate":1732032000,"realFeel":0,"sunDown":1732095540,"sunRise":1732056000,"tempHigh":21,"tempLow":17,"weatherDay":"小雨","weatherNight":"小雨","weatherType":2,"windDirDay":"东北风","windDirNight":"东北风","windLevelDay":"2","windLevelNight":"2","wspdDay":2.4,"wspdNight":2.4}],"forecastDay40":{"fallTrendDesc":[{"briefDesc":"6天降水","desc":"预计未来40天将出现6天降雨","type":2}],"tempTrendDesc":[{"desc":"预计未来40天平均最高温为22℃","type":3}]}},"forecastHours":{"forecastHour":[{"aqiDesc":"优","aqiLevel":1,"aqiValue":21,"humidity":94,"icon":31,"predictTime":1731675600,"pressure":0,"realFeel":29,"temp":23,"uvi":"1","weather":"多云","windDesc":"旋转风","windDir":"N","windLevel":"2","wspd":2.31},{"aqiDesc":"优","aqiLevel":1,"aqiValue":23,"humidity":96,"icon":31,"predictTime":1731679200,"pressure":0,"realFeel":29,"temp":24,"uvi":"1","weather":"多云","windDesc":"西南风","windDir":"SSW","windLevel":"1","wspd":0.8},{"aqiDesc":"优","aqiLevel":1,"aqiValue":25,"humidity":96,"icon":31,"predictTime":1731682800,"pressure":0,"realFeel":29,"temp":25,"uvi":"1","weather":"多云","windDesc":"西北风","windDir":"WNW","windLevel":"1","wspd":0.8},{"aqiDesc":"优","aqiLevel":1,"aqiValue":27,"humidity":94,"icon":31,"predictTime":1731686400,"pressure":0,"realFeel":29,"temp":24,"uvi":"1","weather":"多云","windDesc":"西北风","windDir":"NW","windLevel":"1","wspd":0.9},{"aqiDesc":"优","aqiLevel":1,"aqiValue":30,"humidity":92,"icon":31,"predictTime":1731690000,"pressure":0,"realFeel":28,"temp":24,"uvi":"1","weather":"多云","windDesc":"西北风","windDir":"WNW","windLevel":"1","wspd":1.0},{"aqiDesc":"优","aqiLevel":1,"aqiValue":32,"humidity":91,"icon":31,"predictTime":1731693600,"pressure":0,"realFeel":28,"temp":24,"uvi":"1","weather":"少云","windDesc":"西北风","windDir":"WNW","windLevel":"1","wspd":0.9},{"aqiDesc":"优","aqiLevel":1,"aqiValue":33,"humidity":90,"icon":31,"predictTime":1731697200,"pressure":0,"realFeel":28,"temp":24,"uvi":"1","weather":"多云","windDesc":"西北风","windDir":"NW","windLevel":"1","wspd":0.8},{"aqiDesc":"优","aqiLevel":1,"aqiValue":33,"humidity":90,"icon":31,"predictTime":1731700800,"pressure":0,"realFeel":27,"temp":23,"uvi":"1","weather":"多云","windDesc":"西北风","windDir":"NW","windLevel":"1","wspd":1.1},{"aqiDesc":"优","aqiLevel":1,"aqiValue":33,"humidity":89,"icon":31,"predictTime":1731704400,"pressure":0,"realFeel":27,"temp":23,"uvi":"1","weather":"多云","windDesc":"西北风","windDir":"NNW","windLevel":"1","wspd":1.1},{"aqiDesc":"优","aqiLevel":1,"aqiValue":34,"humidity":94,"icon":31,"predictTime":1731708000,"pressure":0,"realFeel":28,"temp":23,"uvi":"1","weather":"多云","windDesc":"西北风","windDir":"NW","windLevel":"1","wspd":0.9},{"aqiDesc":"优","aqiLevel":1,"aqiValue":34,"humidity":90,"icon":1,"predictTime":1731711600,"pressure":0,"realFeel":28,"temp":24,"uvi":"1","weather":"多云","windDesc":"旋转风","windDir":"N","windLevel":"1","wspd":0.9},{"aqiDesc":"优","aqiLevel":1,"aqiValue":34,"humidity":86,"icon":1,"predictTime":1731715200,"pressure":0,"realFeel":28,"temp":23,"uvi":"1","weather":"多云","windDesc":"东北风","windDir":"NNE","windLevel":"1","wspd":1.0},{"aqiDesc":"优","aqiLevel":1,"aqiValue":34,"humidity":82,"icon":1,"predictTime":1731718800,"pressure":0,"realFeel":29,"temp":25,"uvi":"2","weather":"少云","windDesc":"东北风","windDir":"NNE","windLevel":"1","wspd":1.1},{"aqiDesc":"优","aqiLevel":1,"aqiValue":34,"humidity":76,"icon":1,"predictTime":1731722400,"pressure":0,"realFeel":29,"temp":28,"uvi":"3","weather":"多云","windDesc":"西北风","windDir":"WNW","windLevel":"1","wspd":1.5},{"aqiDesc":"优","aqiLevel":1,"aqiValue":35,"humidity":73,"icon":1,"predictTime":1731726000,"pressure":0,"realFeel":30,"temp":30,"uvi":"4","weather":"多云","windDesc":"西北风","windDir":"WNW","windLevel":"2","wspd":1.7},{"aqiDesc":"优","aqiLevel":1,"aqiValue":36,"humidity":69,"icon":1,"predictTime":1731729600,"pressure":0,"realFeel":32,"temp":30,"uvi":"4","weather":"多云","windDesc":"西北风","windDir":"NW","windLevel":"2","wspd":1.9},{"aqiDesc":"优","aqiLevel":1,"aqiValue":37,"humidity":66,"icon":1,"predictTime":1731733200,"pressure":0,"realFeel":32,"temp":29,"uvi":"4","weather":"多云","windDesc":"西北风","windDir":"NW","windLevel":"2","wspd":2.0},{"aqiDesc":"优","aqiLevel":1,"aqiValue":38,"humidity":62,"icon":1,"predictTime":1731736800,"pressure":0,"realFeel":32,"temp":29,"uvi":"3","weather":"多云","windDesc":"西北风","windDir":"WNW","windLevel":"2","wspd":1.8},{"aqiDesc":"优","aqiLevel":1,"aqiValue":38,"humidity":63,"icon":3,"predictTime":1731740400,"pressure":0,"realFeel":32,"temp":29,"uvi":"2","weather":"阵雨","windDesc":"西北风","windDir":"WNW","windLevel":"2","wspd":1.7},{"aqiDesc":"优","aqiLevel":1,"aqiValue":39,"humidity":65,"icon":3,"predictTime":1731744000,"pressure":0,"realFeel":31,"temp":29,"uvi":"1","weather":"阵雨","windDesc":"东北风","windDir":"NNE","windLevel":"2","wspd":1.6},{"aqiDesc":"优","aqiLevel":1,"aqiValue":40,"humidity":67,"icon":1,"predictTime":1731747600,"pressure":0,"realFeel":30,"temp":28,"uvi":"1","weather":"多云","windDesc":"东北风","windDir":"NE","windLevel":"2","wspd":1.6},{"aqiDesc":"优","aqiLevel":1,"aqiValue":42,"humidity":70,"icon":31,"predictTime":1731751200,"pressure":0,"realFeel":29,"temp":28,"uvi":"1","weather":"多云","windDesc":"东北风","windDir":"NE","windLevel":"1","wspd":1.4},{"aqiDesc":"优","aqiLevel":1,"aqiValue":43,"humidity":72,"icon":31,"predictTime":1731754800,"pressure":0,"realFeel":28,"temp":28,"uvi":"1","weather":"多云","windDesc":"东北风","windDir":"NE","windLevel":"1","wspd":1.2},{"aqiDesc":"优","aqiLevel":1,"aqiValue":45,"humidity":31,"icon":30,"predictTime":1731758400,"pressure":0,"realFeel":29,"temp":28,"uvi":"1","weather":"晴","windDesc":"东北风","windDir":"NE","windLevel":"1","wspd":1.0}]},"lat":22.724442,"lon":114.055193,"provinceName":"广东省","rc":{"c":0},"timezone":8}
def get_city_weather(cityId):
    url='https://h5ctywhr.api.moji.com/weatherDetail'
    headers={'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
    data={"cityId":cityId,"cityType":0}
    r=requests.post(url,headers=headers,json=data)
    result=r.json()

    # today forecast
    forecastToday=dict(
        humidity=f"{result['condition']['humidity']}%",
        temp=f"{result['condition']['temp']}°C",
        realFeel=f"{result['condition']['realFeel']}°C",
        weather=result['condition']['weather'],
        wind=f"{result['condition']['windDir']}{result['condition']['windLevel']}级",
        updateTime=(datetime.datetime.fromtimestamp(result['condition']['updateTime'])+datetime.timedelta(hours=8)).strftime('%H:%M:%S')
    )

    # 24 hours forecast
    forecastHours=[]
    for i in result['forecastHours']['forecastHour']:
        tmp={}
        tmp['PredictTime']=(datetime.datetime.fromtimestamp(i['predictTime'])+datetime.timedelta(hours=8)).strftime('%H:%M')
        tmp['Temperature']=i['temp']
        tmp['Body Temperature']=i['realFeel']
        tmp['Humidity']=i['humidity']
        tmp['Weather']=i['weather']
        tmp['Wind']=f"{i['windDesc']}{i['windLevel']}级"
        forecastHours.append(tmp)
    df_forecastHours=pd.DataFrame(forecastHours).set_index('PredictTime')

    # 7 days forecast
    forecastDays=[]
    day_format={1:'昨天',0:'今天',-1:'明天',-2:'后天'}
    for i in result['forecastDays']['forecastDay']:
        tmp={}
        now=datetime.datetime.fromtimestamp(i['predictDate'])+datetime.timedelta(hours=8)
        diff=(st.session_state.date_time-now).days
        festival=i['festival']
        tmp['PredictDate']=(day_format[diff] if diff in day_format else now.strftime('%m/%d')) + (f' {festival}' if festival != '' else '')
        tmp['Temperature']=f"{i['tempLow']}~{i['tempHigh']}°C"
        tmp['Humidity']=f"{i['humidity']}%"
        tmp['WeatherDay']=i['weatherDay']
        tmp['WeatherNight']=i['weatherNight']
        tmp['WindDay']=f"{i['windDirDay']}{i['windLevelDay']}级"
        tmp['WindNight']=f"{i['windDirNight']}{i['windLevelNight']}级"
        forecastDays.append(tmp)
    df_forecastDays=pd.DataFrame(forecastDays).set_index('PredictDate')
    return forecastToday,df_forecastHours,df_forecastDays
def get_sky(cityName):
    url = 'https://ssch.api.moji.com/citymanage/json/h5/searchCity'
    data = {
        'keyWord': cityName
    }
    res = requests.post(url, data=data)
    try:
        cityId = res.json()['city_list'][0]['cityId']
    except:
        return 'cty_name error'
    url = 'https://h5ctywhr.api.moji.com/weatherDetail'
    data = {"cityId": cityId, "cityType": 0}
    res = requests.post(url, json=data)
    obj = res.json()
    temp = obj['condition']['temp']
    humidity = obj['condition']['humidity']
    weather = obj['condition']['weather']
    wind = obj['condition']['windDir'] + ' ' + str(obj['condition']['windLevel']) + '级'
    tips = obj['condition']['tips']
    city = f"{obj['provinceName']}-{obj['cityName']}"
    return f'''地区:{city}
温度:{temp} 湿度:{humidity}
天气:{weather} 风向:{wind}
提示:{tips}'''
public static List<AlertPO> queryAlert(Integer cityId) {
        try {
            Map<String, Object> paramMap = new HashMap<>();
            String url = "https://h5ctywhr.api.moji.com/weatherthird/alert";
            paramMap.put("cityId", cityId);
            String jsonString = JSON.toJSONString(paramMap);
            String result = HttpUtil.post(url, jsonString);
            JSONObject jsonObject = JSON.parseObject(result);
 
            List<AlertPO> resultList = new ArrayList<>();
            JSONArray alert = jsonObject.getJSONArray("alert");
            if (alert == null) {
                return null;
            }
            for (Object o : alert) {
                JSONObject item = (JSONObject) o;
                AlertPO build = AlertPO.builder()
                        .alertType(item.getInteger("alertTypeId"))
                        .level(item.getInteger("level"))
                        .content(item.getString("content"))
                        .publishTime(item.getLong("publishTime"))
                        .reliveTime(item.getLong("reliveTime"))
                        .publishSector(item.getString("publishSector"))
                        .name(item.getString("name"))
                        .build();
                resultList.add(build);
            }
            return resultList;
        } catch (Exception e) {
            log.error("获取预警信息失败 ! cityId {}", cityId);
            log.error("", e);
        }
        return null;
    }
 
    public static void main(String[] args) {
        queryAlert(2543);
    }
}

 

标签:humidity,aqiDesc,aqiLevel,weather,realFeel,moji,aqiValue
From: https://www.cnblogs.com/gnz48/p/18548752

相关文章

  • Regex 历史 / 规范 / 流派 | JavaScript 匹配 emoji
    注:本文为几篇regex相关合辑。机翻,未校,未整理。RegexHistoryandHow-ToCrystalVillanuevaJan14,2021Aregularexpression,alsoknownasregexorregexp,isaspecialstringthatpresentsitselfrepeatedlyinasearchpattern;today,programmersuse......
  • emoji编码和长度校验
    背景:最近有个需求,在校验输入内容中要校验字符长度,但是里面包含了支持emoji类型在length计数时惊了我,知识盲区--》补课问题描述:1.校验规则:最大12个中文字符,24个英文字符,支持emoji、数字、标点符号2.console.log('......
  • IT软件部落-Emoji表情字符大全增强你的表达能力-记事本也可以有情感,总有一个您用得上,
    这是手绘的吗?不,它是Emoji表情字符,就是普通的文本,你不相信? ......
  • Emoji 表情 速查表
    Emoji俨然已成为程序猿、程序媛居家出行的必备良品。......
  • 帝国cms发布内容保存不了emoji表情的解决方法
    在帝国CMS中发布内容时,如果包含emoji表情,可能会导致保存失败或部分内容丢失。为了解决这一问题,需要从以下几个方面入手:配置数据库支持emoji表情修改帝国CMS的数据库配置文件对字符串进行base64编码和解码步骤1:配置数据库支持emoji表情修改数据库表的字符集......
  • Java 冒泡排序 (Bubble Sort) ✨ 代码版 + Emoji讲解
    冒泡排序的基本思想就是让“大泡泡”不断往上浮,直到整个数组像泡泡浴一样排序好!......
  • 在 commit 里使用 emoji~
    在gitcommit上使用emoji提供了一种简单的方法:仅通过查看所使用的emoji来确定提交的目的或意图,非常好理解,阅读体验很棒。‍效果以我的博客项目为例,可以看到不少的emoji:‍‍使用方法直接在提交信息里写入表情符号的代码即可,例如:$gitcommit-m":art:测试emoj......
  • git提交emoji指南
    emoji指南emojiemoji代码commit说明......
  • markdown emoji
    People:bowtie::bowtie:......
  • C#.NET FRAMEWORK .NET CORE .NET6 .NET8 判断是否Emoji
    C#.NETFRAMEWORK.NETCORE.NET6.NET8判断是否Emoji 工具类:usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;namespaceConsoleThreadTimer{publicclassEmojiUtil{///<s......