天气预报api接口

中华万年历:

请求数据方式:

http://wthrcdn.etouch.cn/weather_mini?city=沈阳
通过城市名字获得天气数据,json数据
http://wthrcdn.etouch.cn/weather_mini?citykey=101070101
通过城市id获得天气数据,json数据
http://wthrcdn.etouch.cn/WeatherApi?citykey=101070101
通过城市id获得天气数据,xml文件数据,
http://wthrcdn.etouch.cn/WeatherApi?city=沈阳
通过城市名字获得天气数据,xml文件数据

获得的json数据包:

{
	"data": {
		"yesterday": {
			"date": "16日星期三",
			"high": "高温 -1℃",
			"fx": "西南风",
			"low": "低温 -16℃",
			"fl": "",
			"type": "晴"
		},
		"city": "沈阳",
		"forecast": [{
				"date": "17日星期四",
				"high": "高温 -3℃",
				"fengli": "",
				"low": "低温 -17℃",
				"fengxiang": "东北风",
				"type": "晴"
			},
			{
				"date": "18日星期五",
				"high": "高温 1℃",
				"fengli": "",
				"low": "低温 -14℃",
				"fengxiang": "西南风",
				"type": "晴"
			},
			{
				"date": "19日星期六",
				"high": "高温 -2℃",
				"fengli": "",
				"low": "低温 -14℃",
				"fengxiang": "西北风",
				"type": "晴"
			},
			{
				"date": "20日星期天",
				"high": "高温 -2℃",
				"fengli": "",
				"low": "低温 -12℃",
				"fengxiang": "西北风",
				"type": "晴"
			},
			{
				"date": "21日星期一",
				"high": "高温 3℃",
				"fengli": "",
				"low": "低温 -10℃",
				"fengxiang": "西南风",
				"type": "晴"
			}
		],
		"ganmao": "昼夜温差很大,易发生感冒,请注意适当增减衣服,加强自我防护避免感冒。",
		"wendu": "-2"
	},
	"status": 1000,
	"desc": "OK"
}

获得的xml数据包:

   
<resp>
    <city>沈阳city>
    <updatetime>16:02updatetime>
    <wendu>-2wendu>
    <fengli>
        
    fengli>
    <shidu>25%shidu>
    <fengxiang>东风fengxiang>
    <sunrise_1>07:11sunrise_1>
    <sunset_1>16:42sunset_1>
    <sunrise_2>sunrise_2>
    <sunset_2>sunset_2>
    <yesterday>
        <date_1>16日星期三date_1>
        <high_1>高温 -1℃high_1>
        <low_1>低温 -16℃low_1>
        <day_1>
            <type_1>type_1>
            <fx_1>西南风fx_1>
            <fl_1>
                
            fl_1>
        day_1>
        <night_1>
            <type_1>type_1>
            <fx_1>西北风fx_1>
            <fl_1>
                
            fl_1>
        night_1>
    yesterday>
    <forecast>
        <weather>
            <date>17日星期四date>
            <high>高温 -3℃high>
            <low>低温 -17℃low>
            <day>
                <type>type>
                <fengxiang>东北风fengxiang>
                <fengli>
                    
                fengli>
            day>
            <night>
                <type>type>
                <fengxiang>东北风fengxiang>
                <fengli>
                    
                fengli>
            night>
        weather>
        <weather>
            <date>18日星期五date>
            <high>高温 1℃high>
            <low>低温 -14℃low>
            <day>
                <type>type>
                <fengxiang>西南风fengxiang>
                <fengli>
                    
                fengli>
            day>
            <night>
                <type>type>
                <fengxiang>北风fengxiang>
                <fengli>
                    
                fengli>
            night>
        weather>
        <weather>
            <date>19日星期六date>
            <high>高温 -2℃high>
            <low>低温 -14℃low>
            <day>
                <type>type>
                <fengxiang>西北风fengxiang>
                <fengli>
                    
                fengli>
            day>
            <night>
                <type>type>
                <fengxiang>西北风fengxiang>
                <fengli>
                    
                fengli>
            night>
        weather>
        <weather>
            <date>20日星期天date>
            <high>高温 -2℃high>
            <low>低温 -12℃low>
            <day>
                <type>type>
                <fengxiang>西北风fengxiang>
                <fengli>
                    
                fengli>
            day>
            <night>
                <type>type>
                <fengxiang>西南风fengxiang>
                <fengli>
                    
                fengli>
            night>
        weather>
        <weather>
            <date>21日星期一date>
            <high>高温 3℃high>
            <low>低温 -10℃low>
            <day>
                <type>type>
                <fengxiang>西南风fengxiang>
                <fengli>
                    
                fengli>
            day>
            <night>
                <type>type>
                <fengxiang>西北风fengxiang>
                <fengli>
                    
                fengli>
            night>
        weather>
    forecast>
    <zhishus>
        <zhishu>
            <name>晨练指数name>
            <value>适宜value>
            <detail>天气不错,空气清新,是您晨练的大好时机,建议不同年龄段的人们积极参加户外健身活动。detail>
        zhishu>
        <zhishu>
            <name>舒适度name>
            <value>较不舒适value>
            <detail>白天天气晴好,但仍会使您感觉偏冷,不很舒适,请注意适时添加衣物,以防感冒。detail>
        zhishu>
        <zhishu>
            <name>穿衣指数name>
            <value>寒冷value>
            <detail>天气寒冷,建议着厚羽绒服、毛皮大衣加厚毛衣等隆冬服装。年老体弱者尤其要注意保暖防冻。detail>
        zhishu>
        <zhishu>
            <name>感冒指数name>
            <value>易发value>
            <detail>昼夜温差很大,易发生感冒,请注意适当增减衣服,加强自我防护避免感冒。detail>
        zhishu>
        <zhishu>
            <name>晾晒指数name>
            <value>基本适宜value>
            <detail>天气不错,午后温暖的阳光仍能满足你驱潮消霉杀菌的晾晒需求。detail>
        zhishu>
        <zhishu>
            <name>旅游指数name>
            <value>较适宜value>
            <detail>天气较好,同时又有微风伴您一路同行。稍冷,较适宜旅游,您仍可陶醉于大自然的美丽风光中。detail>
        zhishu>
        <zhishu>
            <name>紫外线强度name>
            <value>value>
            <detail>紫外线强度较弱,建议出门前涂擦SPF在12-15之间、PA+的防晒护肤品。detail>
        zhishu>
        <zhishu>
            <name>洗车指数name>
            <value>较适宜value>
            <detail>较适宜洗车,未来一天无雨,风力较小,擦洗一新的汽车至少能保持一天。detail>
        zhishu>
        <zhishu>
            <name>运动指数name>
            <value>较不宜value>
            <detail>天气较好,但考虑天气寒冷,推荐您进行室内运动,户外运动时请注意保暖并做好准备活动。detail>
        zhishu>
        <zhishu>
            <name>约会指数name>
            <value>较不适宜value>
            <detail>天气较冷,且室外有风,外出约会可能会让恋人受些苦,最好在温暖的室内促膝谈心。detail>
        zhishu>
        <zhishu>
            <name>雨伞指数name>
            <value>不带伞value>
            <detail>天气较好,您在出门的时候无须带雨伞。detail>
        zhishu>
    zhishus>
resp>

中国天气网城市代码:https://www.cnblogs.com/emo-Studio/p/6840534.html

————————————————

原文链接:https://blog.csdn.net/weixin_40877388/article/details/86526154

你可能感兴趣的:(JAVA)