免費,好用的天氣預報API


不多說直接上!

一、API服務,天氣API

網站:http://api.help.bj.cn/api/

怎么使用網站有很詳細的解釋

 $.ajax({
                type: "GET",    //請求方式     
                url: "http://api.help.bj.cn/apis/weather/?id=101270101",
                dataType: "json",
                data: 'UrlParam',
                success: function (result) {
                    console.log(result);
                }
 });

 

二、http://wthrcdn.etouch.cn

1.通過名字(json數據/xml數據)

接口:1.http://wthrcdn.etouch.cn/weather_mini?city=北京市;

接口:2.http://wthrcdn.etouch.cn/WeatherApi?city=北京市;

2.通過城市id(json數據)

接口:http://wthrcdn.etouch.cn/weather_mini?citykey=101010100;

$.ajax({
                type: "GET",    //請求方式     
                url: "http://wthrcdn.etouch.cn/weather_mini?city=" + '成都',
                dataType: "json",
                success: function (result) {
                    // 今日0 明天1 以此2,3,4
                    let weather = result.data.forecast[0]
                    // for (var i in weather) {

                    //     console.log(i, ":", weather[i]);
                    // } for in 不好用
                    Object.keys(weather).forEach(key => console.log(Object.keys(weather), Object.values(weather)))
                }
            });

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM