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

识别结果

相关推荐
天若有情67312 小时前
【C++原创开源】formort.h:一行头文件,实现比JS模板字符串更爽的链式拼接+响应式变量
开发语言·javascript·c++·git·github·开源项目·模版字符串
好家伙VCC13 小时前
**发散创新:基于Python与ROS的机器人运动控制实战解析**在现代机器人系统开发中,**运动控制**是实现智能行为的核心
java·开发语言·python·机器人
2401_8274999913 小时前
python项目实战09-AI智能伴侣(ai_partner_2-3)
开发语言·python
派葛穆13 小时前
汇川PLC-Python与汇川easy521plc进行Modbustcp通讯
开发语言·python
代码小书生13 小时前
Matplotlib,Python 数据可视化核心库!
python·信息可视化·matplotlib
lzhdim13 小时前
SharpCompress:跨平台的 C# 压缩与解压库
开发语言·c#
嘿嘿嘿x313 小时前
Linux记录过程
linux·开发语言
默 语13 小时前
Records、Sealed Classes这些新特性:Java真的变简单了吗?
java·开发语言·python
架构师老Y13 小时前
013、数据库性能优化:索引、查询与连接池
数据库·python·oracle·性能优化·架构
止观止13 小时前
拥抱 ESNext:从 TC39 提案到生产环境中的现代 JS
开发语言·javascript·ecmascript·esnext