幻域

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 29|回复: 0

分享两个有趣的api

[复制链接]

6696

主题

124

回帖

1万

积分

羽化登仙

是非在己,毁誉由人,得失不论

Rank: 9Rank: 9Rank: 9

UID
1
源力
-4346
灵气
5584
在线时间
375 小时
注册时间
2023-9-16

论坛模范灌水大师在线之王将心比心金点子声明远扬活跃大师管理必备发声者元旦徽章千天纪念

发表于 2024-9-16 18:45:25 | 显示全部楼层 |阅读模式

尽快登录注册

您需要 登录 才可以下载或查看,没有账号?立即注册

x
获取随机小姐姐视频
接口地址:https://api.kuleu.com/api/xjj
返回格式:json
请求方式:get/post
请求示例:https://api.kuleu.com/api/xjj?type=json
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6.     <title>API Video Player</title>
  7. </head>
  8. <body>
  9.     <h1>随机视频播放</h1>
  10.     <div id="videoContainer">
  11.         <video id="videoPlayer" controls>
  12.             您的浏览器不支持HTML5视频播放。
  13.         </video>
  14.     </div>
  15.     <button id="loadVideoButton">加载新视频</button>

  16.     <script>
  17.         // API URL
  18.         const apiUrl = "https://api.kuleu.com/api/xjj?type=json";

  19.         // Function to fetch the video URL from the API
  20.         function loadVideo() {
  21.             fetch(apiUrl)
  22.                 .then(response => response.json())
  23.                 .then(data => {
  24.                     if (data.code === 200) {
  25.                         const videoUrl = data.video;
  26.                         const videoPlayer = document.getElementById("videoPlayer");
  27.                         videoPlayer.src = videoUrl;
  28.                     } else {
  29.                         console.error("无法获取视频:", data.msg);
  30.                     }
  31.                 })
  32.                 .catch(error => {
  33.                     console.error("请求错误:", error);
  34.                 });
  35.         }

  36.         // Event listener for the button
  37.         document.getElementById("loadVideoButton").addEventListener("click", loadVideo);
  38.     </script>
  39. </body>
  40. </html>
复制代码

chatgpt生成的html代码调用:如上
随机猫咪图片
接口地址:https://api.thecatapi.com/v1/images/search 33
返回格式:json
请求方式:get
请求示例:https://api.thecatapi.com/v1/images/search?limit=1 42
示例html:无
世界上一共有三个Cthulhu,你,我,他
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

站长推荐上一条 /1 下一条

QQ|Archiver|手机版|小黑屋|幻域 |网站地图

GMT+8, 2025-5-13 09:17 , Processed in 0.059471 second(s), 30 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表