快手视频解析工具 - 免费在线解析快手视频
<!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" onblur="validateUrl()">
<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>
const urlRegex = /^https?:\/\/www\.kuaishou\.com\/video\/[a-zA-Z0-9]{12,}$/;
const apiUrl = 'http://y.ovoa.cc/api/kuaishou.php?url=';
const $urlInput = $('#url');
const $submitBtn = $('#submit');
const $result = $('.result');
const $modal = $('.modal');
const $modalTitle = $('.modal .title');
const $modalAuthorImg = $('.modal .author img');
const $modalAuthorP = $('.modal .author p');
const $modalVideo = $('.modal video');
const $modalClose = $('.modal .close');
function validateUrl() {
const url = $urlInput.val();
if (url && !urlRegex.test(url)) {
alert('请输入正确的快手视频链接!');
$urlInput.val('').focus();
}
}
function parseVideo(data) {
if (!data || typeof data !== 'object') {
alert('返回数据格式不正确');
return;
}
if (data.msg === '解析成功') {
$result.empty();
const items = data.data;
if (items.length > 0) {
$.each(items, function (index, item) {
const card = $('<div>').addClass('card');
const img = $('<img>').attr('src', item.cover);
const info = $('<div>').addClass('info');
const title = $('<h3>').text(item.title);
const author = $('<p>').text(item.author);
const avatar = $('<img>').attr('src', item.avatar).attr('alt', '头像');
info.append(title, author);
card.append(img, info);
$result.append(card);
card.on('click', function () {
const videoUrl = item.url;
if (!/^https?:\/\/.*\.(mp4|avi|mov|wmv)$/.test(videoUrl)) {
alert('不支持的视频格式!');
return;
}
$modalTitle.text(item.title);
$modalAuthorImg.attr('src', item.avatar);
$modalAuthorP.text(item.author);
$modalVideo.attr('src', videoUrl);
$modal.show();
});
});
} else {
$result.append($('<p>').text('没有找到相关视频'));
}
} else {
alert(data.msg);
}
}
$submitBtn.on('click', function () {
const url = $urlInput.val();
if (url) {
if (!urlRegex.test(url)) {
alert('请输入正确的快手视频链接!');
$urlInput.val('').focus();
return;
}
$.ajax({
url: apiUrl + url,
type: 'GET',
dataType: 'json',
success: parseVideo,
error: function () {
alert('解析失败');
}
});
}
});
$modalClose.on('click', function () {
$modal.hide();
$modalVideo.attr('src', '');
});
</script>
</code></pre>
</body>
</html>
原文地址: https://www.cveoy.top/t/topic/mDCO 著作权归作者所有。请勿转载和采集!