youtube - 如何从 YouTube 实时获取订阅信息
问题描述
我不知道某些 YouTube 频道如何获得即时订阅者每当您使用此脚本时,您都会得到一个固定的计数器,例如 15K 15000 静态出现,并且在 16000 频道到达之前,数字不会像 15001 那样瞬间移动
来自使用此功能的 YouTube 频道之一的图片
这是我使用的文件,但需要修改以从 YouTube API 获得更好的信息
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>YouTube API</title>
</head>
<body>
YouTube Subscribers
<div id="subCount"></div>
<script>
// Get Subscribers
const youtubeKey = ' ADD YOUR KEY HERE';
const youtubeUser = ' ADD YOUR USER ID HERE';
const subCount = document.getElementById('subCount');
let getSubscribers = () => {
fetch(`https://www.googleapis.com/youtube/v3/channels?part=statistics&id=${youtubeUser}&key=${youtubeKey}`)
.then(response => {
return response.json()
})
.then(data => {
console.log(data);
subCount.innerHTML = data["items"][0].statistics.subscriberCount;
})
}
getSubscribers();
</script>
</body>
</html>
解决方案
推荐阅读
- python-3.x - 如何从熊猫数据框中的列中删除不需要的文本
- c# - c# wpf treeviewitem with contextmenu
- python - 如何使用 scipy.ndimage.interpolate 在 3d 中随机旋转 numpy 数组?
- c# - 如何在 mvc 中访问 _layout.cshtml 中的单个视图?
- bash - 从 /etc/rc.local 运行的脚本问题
- amazon-web-services - moto cognito sign_up 功能不起作用
- python - 在 python-pptx 中使用循环创建多张幻灯片并将数据帧写入幻灯片
- angular7 - 调试 Angular 代码时无法在 Google Chrome 中查看变量值
- php - 为什么我不能通过 php cURL 抓取远程站点数据?
- django - 如何从 django 中与外键链接的所有 id 中提取所有对象?