1.获取随机小姐姐视频
接口地址:https://api.kuleu.com/api/xjj
返回格式:json
请求方式:get/post
请求示例:https://api.kuleu.com/api/xjj?type=json
chatgpt生成的html代码调用:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>API Video Player</title>
</head>
<body>
<h1>随机视频播放</h1>
<div id="videoContainer">
<video id="videoPlayer" controls>
您的浏览器不支持HTML5视频播放。
</video>
</div>
<button id="loadVideoButton">加载新视频</button>
<script>
// API URL
const apiUrl = "https://api.kuleu.com/api/xjj?type=json";
// Function to fetch the video URL from the API
function loadVideo() {
fetch(apiUrl)
.then(response => response.json())
.then(data => {
if (data.code === 200) {
const videoUrl = data.video;
const videoPlayer = document.getElementById("videoPlayer");
videoPlayer.src = videoUrl;
} else {
console.error("无法获取视频:", data.msg);
}
})
.catch(error => {
console.error("请求错误:", error);
});
}
// Event listener for the button
document.getElementById("loadVideoButton").addEventListener("click", loadVideo);
</script>
</body>
</html>
- 随机猫咪图片
接口地址:https://api.thecatapi.com/v1/images/search
返回格式:json
请求方式:get
请求示例:https://api.thecatapi.com/v1/images/search?limit=1
示例html:
photo.zip (958 字节)
(第二个写得挺有品味的)求赞