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']])

识别结果

相关推荐
weitingfu15 小时前
Excel VBA 入门到精通(二):变量、数据类型与运算符
java·大数据·开发语言·学习·microsoft·excel·vba
foundbug99915 小时前
无人机离散系统模型预测控制(MPC)MATLAB实现
开发语言·matlab·无人机
爱写代码的小朋友15 小时前
使用 Nuitka 打包 Python 应用:从入门到进阶
开发语言·python
不屈的铝合金15 小时前
Python入门:数字类型与运算
python·数据类型·python类型判断与转换·python运算符优先级
yuan1999715 小时前
C# 断点续传下载文件工具设计与实现
开发语言·c#
想唱rap15 小时前
线程之条件变量和生产消费模型
java·服务器·开发语言·数据库·mysql·ubuntu
智算菩萨15 小时前
【Python图像处理】3 OpenCV核心操作与图像基本变换
图像处理·python·opencv
春蕾夏荷_72829772515 小时前
pyside2 打包发布exe文件
python
Boop_wu15 小时前
[Java 算法] 栈
java·开发语言·算法
来自远方的老作者15 小时前
第7章 运算符-7.5 比较运算符
开发语言·数据结构·python·算法·代码规范·比较运算符