查看: 826|回复: 2
|
【JavaScript】大马Covid-19每日更新
[复制链接]
|
|
https://feed.w3spaces.com/covid19.html
以下是源码,不过我已经省略掉API Key,感兴趣的人必须自己到RapidApi.com申请:
- <!DOCTYPE html>
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <link rel="stylesheet" type="text/css" href="styles.css">
- <style>
- div { font-size: 18px;}
- </style>
- <title>Covid-19 Malaysia</title>
- </head>
- <body>
- <h2>Covid-19 Tracking in Malaysia</h2>
- <h4><a href="https://rapidapi.com/organization/slotixsro">Freemium API that grabs live Coronavirus statistics from https://www.worldometers.info/coronavirus/#countries web site periodically. </a></h4>
- <div id="track">
- </div>
- <script>fetch("https://covid-19-tracking.p.rapidapi.com/v1/malaysia", {
- "method": "GET",
- "headers": {
- "x-rapidapi-key": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
- "x-rapidapi-host": "covid-19-tracking.p.rapidapi.com"
- }
- })
- .then(response => response.json())
- .then(data => {
- console.log(data);
- const output = document.getElementById("track");
- output.innerText=JSON.stringify(data);
- })
- </script>
- </body>
- </html>
复制代码
|
|
|
|
|
|
|
|
楼主 |
发表于 29-6-2021 06:32 PM
|
显示全部楼层
已经更新了UI/UX,阅读的更顺眼了!
|
|
|
|
|
|
|
|
楼主 |
发表于 1-7-2021 11:18 PM
|
显示全部楼层
由于是免费的API, 大家只能等多一个月才能看到Covid-19数据显示在我的网页,它有限定只能每个月100笔请求。 |
|
|
|
|
|
|
| |
本周最热论坛帖子
|