Python获取QQ音乐歌单歌曲

准备工作

歌单分享的url地址

比如: https://i.y.qq.com/n2/m/share/details/taoge.html?hosteuin=oKvzoK4l7evk7n**&id=9102222552&appversion=130605&ADTAG=wxfshare&appshare=iphone_wx

代码实现

复制代码
def mu(share_url):
    share_url = share_url.split('id=')[1].split('&')[0]
    print('share id: ', share_url)

    url = f'https://i.y.qq.com/n2/m/share/details/interactive_playlist.html?ADTAG=ryqq.playlist&id={share_url}'
    headers = {
        'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1'
    }
    r = requests.get(url, headers=headers)
    res = r.content.decode('utf-8')

    res = res.split('firstPageData =')[1].split('"keywords":[')[0][:-1] + '}}'.strip()
    res = res.replace('false', '"false"').replace('null', '"null"')
    res = json.loads(res)

    print('title: ', res['taogeData']['title'])
    print('pic: ', res['taogeData']['picurl'])
    print('song list: ', [{'song title: ': i['title'], 'singer: ': i['singer'][0]['name']} for i in res['taogeData']['songlist']])

识别结果

相关推荐
z***y862几秒前
Java数据挖掘开发
java·开发语言·数据挖掘
程序员爱钓鱼15 分钟前
Python 编程实战 · 进阶与职业发展:数据分析与 AI(Pandas、NumPy、Scikit-learn)
后端·python·trae
软件开发技术深度爱好者19 分钟前
Python库/包/模块管理工具
开发语言·python
bubiyoushang88827 分钟前
基于MATLAB的自然图像梯度分布重尾特性验证方案
开发语言·matlab
程序员爱钓鱼28 分钟前
Python 编程实战 · 进阶与职业发展:Web 全栈(Django / FastAPI)
后端·python·trae
MSTcheng.1 小时前
【C++STL】priority_queue 模拟实现与仿函数实战
开发语言·c++
小年糕是糕手1 小时前
【C++】C++入门 -- inline、nullptr
linux·开发语言·jvm·数据结构·c++·算法·排序算法
郝学胜-神的一滴1 小时前
Python中一切皆对象:深入理解Python的对象模型
开发语言·python·程序人生·个人开发
csbysj20201 小时前
JSP 隐式对象
开发语言
星期天22 小时前
3.2联合体和枚举enum,还有动态内存malloc,free,calloc,realloc
c语言·开发语言·算法·联合体·动态内存·初学者入门·枚举enum