解析抖音视频,并且带昵称.签名.描述.头像的数据
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>抖音视频解析器</title>
</head>
<body>
<h1>抖音视频解析器</h1>
<div>
<label for="url">输入抖音视频链接:</label>
<input type="text" id="url" placeholder="请输入视频链接">
<button id="parseButton">解析视频</button>
</div>
<div id="response">
<h2>响应详情</h2>
<p><strong>状态码:</strong> <span id="code"></span></p>
<p><strong>消息:</strong> <span id="msg"></span></p>
</div>
<div id="video">
<h2>视频详情</h2>
<p><strong>播放地址:</strong> <span id="play_url"></span></p>
<p><strong>视频文件地址:</strong> <span id="video_url"></span></p>
<p><strong>解析耗时:</strong> <span id="parse_time"></span></p>
</div>
<div id="additional_data">
<h2>其他数据</h2>
<div id="author">
<p><strong>昵称:</strong> <span id="nickname"></span></p>
<p><strong>签名:</strong> <span id="signature"></span></p>
<p><strong>描述:</strong> <span id="desc"></span></p>
<p><strong>头像:</strong> <img id="avatar" src="" alt="头像" width="100"></p>
</div>
</div>
<script>
document.getElementById('parseButton').addEventListener('click', async () => {
const url = document.getElementById('url').value;
if (!url) {
alert('请输入视频链接。');
return;
}
try {
const response = await fetch(`https://api.xinyew.cn/api/douyinjx?url=${encodeURIComponent(url)}`);
const result = await response.json();
if (result.code === 200) {
document.getElementById('code').textContent = result.code;
document.getElementById('msg').textContent = result.msg;
document.getElementById('play_url').textContent = result.data.play_url;
document.getElementById('video_url').textContent = result.data.video_url;
document.getElementById('parse_time').textContent = `${result.data.parse_time} 毫秒`;
const additionalData = result.data.additional_data[0];
document.getElementById('nickname').textContent = additionalData.nickname;
document.getElementById('signature').textContent = additionalData.signature;
document.getElementById('desc').textContent = additionalData.desc;
document.getElementById('avatar').src = additionalData.url;
} else {
alert(`错误:${result.msg}`);
}
} catch (error) {
console.error('获取API数据时出错:', error);
alert('无法获取视频信息,请稍后重试。');
}
});
</script>
</body>
</html>
版权说明
文章采用: 《署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)》许可协议授权。版权声明:本站资源来自互联网收集,仅供用于学习和交流,请勿用于商业用途。如有侵权、不妥之处,请联系客服并出示版权证明以便删除!