用html5+jq写个网站需要有样式api接口httpyovoaccapikuaishouphpurl= 参数 msg:解析成功 avatar:用户头像 author:用户名字 title:作品标题 cover:作品封面 url:解析后无水印地址
<!DOCTYPE html>
<html>
<head>
<title>快手视频解析</title>
<meta charset="utf-8">
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<style>
body {
margin: 0;
padding: 0;
background-color: #f8f8f8;
font-family: Arial, sans-serif;
}
.container {
max-width: 960px;
margin: 0 auto;
padding: 20px;
background-color: #fff;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
h1 {
text-align: center;
margin-top: 0;
}
form {
display: flex;
flex-direction: column;
align-items: center;
margin-top: 20px;
}
input[type=text] {
padding: 10px;
border: 1px solid #ddd;
border-radius: 5px;
width: 100%;
max-width: 600px;
margin-bottom: 10px;
}
button {
padding: 10px 20px;
background-color: #49c8f0;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.2s;
}
button:hover {
background-color: #37a1c2;
}
.result {
margin-top: 20px;
display: flex;
flex-wrap: wrap;
justify-content: center;
}
.card {
width: 300px;
margin: 10px;
background-color: #fff;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
overflow: hidden;
cursor: pointer;
transition: transform 0.2s;
}
.card:hover {
transform: translateY(-5px);
}
.card img {
width: 100%;
height: 200px;
object-fit: cover;
}
.card .info {
padding: 10px;
}
.card .info h3 {
margin-top: 0;
margin-bottom: 5px;
}
.card .info p {
margin: 0;
font-size: 14px;
color: #888;
}
.modal {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
display: flex;
align-items: center;
justify-content: center;
z-index: 999;
}
.modal .content {
background-color: #fff;
padding: 20px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
max-width: 800px;
width: 100%;
max-height: 80%;
overflow-y: auto;
position: relative;
}
.modal .content .close {
position: absolute;
top: 10px;
right: 10px;
font-size: 24px;
color: #888;
cursor: pointer;
}
.modal .content .title {
margin-top: 0;
margin-bottom: 10px;
font-size: 24px;
font-weight: bold;
text-align: center;
}
.modal .content .author {
margin-bottom: 20px;
display: flex;
align-items: center;
justify-content: center;
}
.modal .content .author img {
width: 40px;
height: 40px;
border-radius: 50%;
margin-right: 10px;
}
.modal .content .author p {
margin: 0;
font-size: 16px;
font-weight: bold;
}
.modal .content video {
width: 100%;
height: auto;
max-height: 80%;
margin-bottom: 10px;
}
</style>
</head>
<body>
<div class="container">
<h1>快手视频解析</h1>
<form>
<label for="url">请输入快手视频链接:</label>
<input type="text" id="url" name="url" placeholder="例如:https://www.kuaishou.com/video/xxxxxxxxxxxx">
<button type="button" id="submit">解析</button>
</form>
<div class="result"></div>
</div>
<pre><code><div class="modal">
<div class="content">
<span class="close">&times;</span>
<h2 class="title"></h2>
<div class="author">
<img src="" alt="头像">
<p></p>
</div>
<video controls></video>
</div>
</div>
<script>
$(function () {
$('#submit').on('click', function () {
var url = $('#url').val();
if (url) {
$.ajax({
url: 'http://y.ovoa.cc/api/kuaishou.php?url=' + url,
type: 'GET',
dataType: 'json',
success: function (data) {
if (data.msg === '解析成功') {
var result = $('.result');
result.empty();
var items = data.data;
if (items.length > 0) {
$.each(items, function (index, item) {
var card = $('<div>').addClass('card');
var img = $('<img>').attr('src', item.cover);
var info = $('<div>').addClass('info');
var title = $('<h3>').text(item.title);
var author = $('<p>').text(item.author);
var avatar = $('<img>').attr('src', item.avatar).attr('alt', '头像');
info.append(title, author);
card.append(img, info);
result.append(card);
card.on('click', function () {
$('.modal .title').text(item.title);
$('.modal .author img').attr('src', item.avatar);
$('.modal .author p').text(item.author);
$('.modal video').attr('src', item.url);
$('.modal').show();
});
});
} else {
result.append($('<p>').text('没有找到相关视频'));
}
} else {
alert(data.msg);
}
},
error: function () {
alert('解析失败');
}
});
}
});
$('.modal .close').on('click', function () {
$('.modal').hide();
$('.modal video').attr('src', '');
});
});
</script>
</code></pre>
</body>
</html>
原文地址: https://www.cveoy.top/t/topic/bc3B 著作权归作者所有。请勿转载和采集!