-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
51 lines (45 loc) · 1.39 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>粉丝进度条</title>
<style>
#progress-bar {
width: 100%;
background-color: #ddd;
}
#progress {
width: 0%;
background-color: #4CAF50;
text-align: center;
color: white;
padding: 10px 0;
}
</style>
</head>
<body>
<div id="progress-bar">
<div id="progress">0%</div>
</div>
<script>
// 目标粉丝数
const totalFans = 100; // 您可以根据需要调整这个数值
// 使用 Fetch API 获取 Bilibili 用户的粉丝人数
fetch('https://api.bilibili.com/x/relation/stat?vmid=33768156')
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok ' + response.statusText);
}
return response.json();
})
.then(data => {
const currentFans = data.data.follower;
const percentage = (currentFans / totalFans) * 100;
// 更新进度条
document.getElementById('progress').style.width = percentage + '%';
document.getElementById('progress').textContent = Math.round(percentage) + '%';
})
.catch(error => console.error('Fetch Error:', error));
</script>
</body>
</html>