angular框架下的跨域问题(获取天气数据)

时间:2023-03-08 22:27:58

1、新浪天气:http://php.weather.sina.com.cn/iframe/index/w_cl.php?code=js&day=0&city=&dfc=1&charset=utf-8

2、中国天气网:1)http://www.weather.com.cn/data/sk/101010100.html  2)http://www.weather.com.cn/data/cityinfo/101010100.html

3、中国万年历:1)http://wthrcdn.etouch.cn/weather_mini?city=北京  2)http://wthrcdn.etouch.cn/weather_mini?citykey=101010100

4、和风天气(天气服务1天免费试用,城市查询服务免费,不推荐使用)

var key='';//自行输入获取的key
$.getJSON('https://free-api.heweather.com/v5/now?city=苏州&key='+key,function (data) { })

5、心知天气

官方链接:https://github.com/seniverse/seniverse-api-demos/blob/master/javascript/jsonp.html

参考链接:http://www.jianshu.com/p/fa6e5eb6ba86

6、百度API

          var type='jsonp';
var ak='';//自行输入百度获取的ak
var url='http://api.map.baidu.com/location/ip?callback=JSON_CALLBACK'; //通过IP获取当前地理位置
$http({
method: type, // 支持jsonp,
url: url,
params: { // 请求的参数
ak: ak
},
}).success(function (locationData) { })