不多说直接上!

一、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)))
}
});

最新文章

  1. 【转】【整理】将Linux脚本中的正常输出,警告,错误等信息输出到文件中
  2. 029. aps.net中DataView中详细信息的跳转显示
  3. Failure is not fatal, but failure to change might be.
  4. (转载).Net HttpPost的发送和接收示例代码
  5. JavaScript 应用开发 #5:为完成的任务添加样式
  6. Asp.Net Mvc后台数据验证自测小Demo
  7. VitamioBundle-master
  8. 第一次用IIS发布网站时遇到的两个问题
  9. 【HDU1272】小希的迷宫(并查集基础题)
  10. UITableView控制头部View
  11. vbs和qtp一些脚本
  12. Skewed Sorting
  13. brew的MAC安装
  14. FORM执行查询的各种方法
  15. python "import this"
  16. Celery 1
  17. [SYSS-2018-033]: Fujitsu Wireless Keyboard Set LX901 - Keystroke Injection Vulnerability
  18. awk基本用法
  19. 造轮子,模仿WPF的UI框架,还没完善。。。
  20. Swift 静态派发和动态派发

热门文章

  1. 什么是CAP?
  2. 26、linux下安装MongoDB
  3. 4、VMware虚拟机相关配置
  4. csu-acm 1503: 点到圆弧的距离
  5. JavaScript编写计算器的发展史
  6. docker 搭建 redis 集群(哨兵模式)
  7. Kafka:docker安装Kafka消息队列
  8. BUU mrctf shit
  9. 转:nginx服务器配置
  10. abp知识