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

识别结果

相关推荐
晞子的技术札记16 小时前
单相Heric并网逆变器工作原理及MATLAB仿真测试
开发语言·matlab
李云龙炮击平安线程16 小时前
Python中的接口、抽象基类和协议
开发语言·后端·python·面试·跳槽
深圳华秋电子16 小时前
靠谱的EDA AI助手生产厂家——华秋KiCad
人工智能·python
十五年专注C++开发16 小时前
Qt deleteLater作用及源码分析
开发语言·c++·qt·qobject
xyq202416 小时前
Redis 列表(List)
开发语言
you-_ling16 小时前
线程及进程间通信
java·开发语言
徐先生 @_@|||16 小时前
时间序列异常检测框架CrossAD论文阅读
经验分享·python·机器学习
weixin_3954489117 小时前
build_fsd_luyan_from_rm.py-cursor0225
开发语言·python
先做个垃圾出来………17 小时前
Python常见文件操作
linux·数据库·python
tod11317 小时前
OS 核心知识点全解析(一)
linux·开发语言·面试经验