js 获取天气预报

不逼逼,直接看方法

1.2345天气预报插件 iframe 链接 http://tianqi.2345.com/plugin/

2.百度天气接口

$. ajax({
    url: "http://api.map.baidu.com/telematics/v3/weather?location=北京&output=json&ak=H7W5CxI0BPzKtwGcBHmpGPAz50xP1Qjw",
dataType: "jsonp",
jsonpCallback: "admin_cross",
success : function( data){
     console. log( data)
}
})

3.心知天气 链接 https://www.seniverse.com/doc

4.通过万年历获取天气


         $. getScript( 'http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js', function ( _result) {
             console. log( remote_ip_info); //定位城市
             if ( remote_ip_info. ret == '1') {
                 $. ajax({ //获取天气
                     type: "GET",
                     url: "http://wthrcdn.etouch.cn/weather_mini?city=" + remote_ip_info. city,
                     data: "",
                     success : function ( msg) {
                         var res = eval( '(' + msg + ')');
                         //alert(msg);
                         if ( res. status == 1000) {
                             //请求成功
                             console. log( res)
                             console. log( res. data. forecast[ 0]. fengli. substring( 9, res. data. forecast[ 0]. fengli. length - 3))
                        }
                    }
                });
            }
        });

猜你喜欢

转载自blog.csdn.net/uncle_long/article/details/80437069