标签:set css secret doctype utf-8 func version cti str
<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>天气API - tianqiapi.com</title> <style> * { padding: 0; margin: 0; } body { text-align: left; color: #808080; font-size: 14px; padding-top: 0px; padding-left: 0px; } </style> </head> <body> <!--【济南】晴 9°/21°,8:00更新~--> <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script> <script> $.ajax({ type: ‘GET‘, url: ‘https://www.tianqiapi.com/api/‘, data: ‘version=v1&city=‘, dataType: ‘JSON‘, error: function () { alert(‘网络错误‘); }, success: function (res) { uptime = res.update_time.substring(11); uptime = uptime.substring(0,uptime.length-3); $(‘body‘).append(‘【‘ + res.city + ‘】‘ + res.data[0].wea + ‘ ‘ + res.data[0].tem1 + ‘/‘ + res.data[0].tem2 + ‘,‘ + uptime + ‘更新~‘); } }); </script> </body> </html>
代码保存为HTML, 直接运行就可以看到效果了, 默认展示当前城市天气
默认获取7天, 不需要appid和appsecret, 没有调用次数、频率和IP限制, 请放心使用!
接口调用,就是这么简单! curl "https://www.tianqiapi.com/api/?version=v1"
标签:set css secret doctype utf-8 func version cti str
原文地址:https://www.cnblogs.com/ccjin/p/10588571.html