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

识别结果

相关推荐
alvin_200530 分钟前
python之OpenGL应用(五)变换
python·opengl
燕山罗成37 分钟前
JAVA多线程基础
java·开发语言
深蓝电商API38 分钟前
服务器部署爬虫:Supervisor 进程守护
爬虫·python
是梦终空11643 分钟前
Python深度学习入门:TensorFlow 2.0/Keras实战
jvm·数据库·python
Yvonne爱编码1 小时前
JAVA数据结构 DAY7-二叉树
java·开发语言·数据结构
竹林8181 小时前
用Python requests搞定Cookie登录,我绕过了三个大坑才成功
爬虫·python·自动化运维
En^_^Joy1 小时前
JavaScript入门指南:从零到精通
开发语言·javascript
于先生吖1 小时前
2026 新版 Java 同城上门家政服务系统源码 完整可运营
java·开发语言
MIXLLRED1 小时前
Python模块详解(一)—— socket 和 threading 模块
开发语言·python·socket·threading
csbysj20201 小时前
桥接模式(Bridge Pattern)
开发语言