<!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>&lt;div class=&quot;modal&quot;&gt;
	&lt;div class=&quot;content&quot;&gt;
		&lt;span class=&quot;close&quot;&gt;&amp;times;&lt;/span&gt;
		&lt;h2 class=&quot;title&quot;&gt;&lt;/h2&gt;
		&lt;div class=&quot;author&quot;&gt;
			&lt;img src=&quot;&quot; alt=&quot;头像&quot;&gt;
			&lt;p&gt;&lt;/p&gt;
		&lt;/div&gt;
		&lt;video controls&gt;&lt;/video&gt;
	&lt;/div&gt;
&lt;/div&gt;

&lt;script&gt;
	$(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 &gt; 0) {
								$.each(items, function (index, item) {
									var card = $('&lt;div&gt;').addClass('card');
									var img = $('&lt;img&gt;').attr('src', item.cover);
									var info = $('&lt;div&gt;').addClass('info');
									var title = $('&lt;h3&gt;').text(item.title);
									var author = $('&lt;p&gt;').text(item.author);
									var avatar = $('&lt;img&gt;').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($('&lt;p&gt;').text('没有找到相关视频'));
							}
						} else {
							alert(data.msg);
						}
					},
					error: function () {
						alert('解析失败');
					}
				});
			}
		});

		$('.modal .close').on('click', function () {
			$('.modal').hide();
			$('.modal video').attr('src', '');
		});
	});
&lt;/script&gt;
</code></pre>
</body>
</html>
用html5+jq写个网站需要有样式api接口httpyovoaccapikuaishouphpurl= 参数 msg:解析成功 avatar:用户头像 author:用户名字 title:作品标题 cover:作品封面 url:解析后无水印地址

原文地址: https://www.cveoy.top/t/topic/bc3B 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录