免费,好用的天气预报API
2024-09-07 15:37:00
不多说直接上!
一、API服务,天气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)))
}
});
最新文章
- 【转】【整理】将Linux脚本中的正常输出,警告,错误等信息输出到文件中
- 029. aps.net中DataView中详细信息的跳转显示
- Failure is not fatal, but failure to change might be.
- (转载).Net HttpPost的发送和接收示例代码
- JavaScript 应用开发 #5:为完成的任务添加样式
- Asp.Net Mvc后台数据验证自测小Demo
- VitamioBundle-master
- 第一次用IIS发布网站时遇到的两个问题
- 【HDU1272】小希的迷宫(并查集基础题)
- UITableView控制头部View
- vbs和qtp一些脚本
- Skewed Sorting
- brew的MAC安装
- FORM执行查询的各种方法
- python ";import this";
- Celery 1
- [SYSS-2018-033]: Fujitsu Wireless Keyboard Set LX901 - Keystroke Injection Vulnerability
- awk基本用法
- 造轮子,模仿WPF的UI框架,还没完善。。。
- Swift 静态派发和动态派发