核心数据源:听歌排行接口
这个接口包含了你听歌最多的 100 首歌的详细数据。
接口 URL:https://music.163.com/weapi/v1/play/record
关键字段:
playCount: 播放次数
score: 个人热度分
song.pop: 全站热度
song.publishTime: 发行时间。
限制 :返回前 100 首(所有时间)或者前 100 首(最近一周)。
如何获取数据?
- 打开网易云网页版听歌排行榜 https://music.163.com/#/user/songs/rank?id=114514。 114514为你的user id
- 打开 F12 Network,选择 Fetch/XHR。
找到 record 请求。
右键 -> Copy Response,保存为 netease_data.json。
数据解析
拿到的 JSON 数据非常丰富。核心字段解析如下:
JSON
{
"playCount": 156, // 播放次数
"score": 100, // 个人热度分(100-0,基于次数计算的权重)
"song": {
"name": "歌曲名",
"dt": 242000, // 歌曲时长 (毫秒)
"pop": 100, // 【关键】全站热度 (0-100)。100表示全网爆火,<20表示极其冷门
"publishTime": 1431187200000 // 发行时间戳
...
}
}
Python 脚本分析
注意:需要安装pandas openpyxl库。
在 netease_data.json 同目录创建analysis.py,贴入下面代码,运行。
import json
import pandas as pd
import os
# --- 配置 ---
json_filename = 'netease_data.json'
excel_filename = '我的网易云听歌数据_Top10版.xlsx'
# 1. 读取 JSON 文件
if not os.path.exists(json_filename):
print(f"❌ 错误:找不到文件 {json_filename}")
print("👉 请确保你已经把 Network 里复制的响应内容保存到了这个文件中。")
exit()
with open(json_filename, 'r', encoding='utf-8') as f:
raw_data = json.load(f)
# --- 定义通用分析与展示函数 ---
def analyze_and_print(record_list, time_label):
"""
处理数据并打印 Top 10 榜单
"""
if not record_list:
print(f"\n⚠️ 【{time_label}】数据为空 (可能没听歌或接口没返回)")
return pd.DataFrame()
print(f"\n{'='*20} 📅 分析周期:{time_label} {'='*20}")
cleaned_data = []
for item in record_list:
song = item['song']
artists = ", ".join([ar['name'] for ar in song['ar']])
cleaned_data.append({
'歌名': song['name'],
'歌手': artists,
'播放次数': item['playCount'],
'个人热度(score)': item['score'],
'全站热度(pop)': song['pop'],
'时长(秒)': song['dt'] / 1000,
'总听歌时长(分)': round((song['dt'] / 1000 * item['playCount']) / 60, 2)
})
df = pd.DataFrame(cleaned_data)
# 1. 🏆 绝对真爱榜 (按播放次数)
top_love = df.sort_values(by='播放次数', ascending=False).head(10).reset_index(drop=True)
top_love.index += 1
print("\n❤️ 【绝对真爱榜】(播放次数 Top 10):")
print(top_love[['歌名', '歌手', '播放次数']].to_string())
# 2. ⏳ 时间黑洞榜 (按总时长)
top_time = df.sort_values(by='总听歌时长(分)', ascending=False).head(10).reset_index(drop=True)
top_time.index += 1
print("\n⏳ 【时间黑洞榜】(消耗时长 Top 10):")
print(top_time[['歌名', '总听歌时长(分)', '播放次数']].to_string())
# 3. 💎 小众品味榜 (全站热度 < 50,按播放次数排)
niche_songs = df[df['全站热度(pop)'] < 50].sort_values(by='播放次数', ascending=False).head(10).reset_index(drop=True)
if not niche_songs.empty:
niche_songs.index += 1
print("\n💎 【小众品味榜】(全站冷门 Top 10):")
print(niche_songs[['歌名', '歌手', '播放次数', '全站热度(pop)']].to_string())
else:
print("\n💎 【小众品味榜】:没有发现全站热度低于 50 的歌曲。")
return df
# --- 主程序逻辑 ---
print("🚀 正在启动数据分析引擎...")
# 分别分析两份数据
df_all = analyze_and_print(raw_data.get('allData', []), "所有时间")
df_week = analyze_and_print(raw_data.get('weekData', []), "最近一周")
# 导出 Excel
print(f"\n{'='*50}")
try:
with pd.ExcelWriter(excel_filename) as writer:
if not df_all.empty:
df_all.sort_values(by='播放次数', ascending=False).to_excel(writer, sheet_name='所有时间_完整榜单', index=False)
if not df_week.empty:
df_week.sort_values(by='播放次数', ascending=False).to_excel(writer, sheet_name='最近一周_完整榜单', index=False)
print(f"💾 完整数据已导出至:{excel_filename}")
except PermissionError:
print(f"❌ 导出失败:请先关闭正在打开的 Excel 文件!")
except Exception as e:
print(f"❌ 发生未知错误:{e}")
运行结果