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

识别结果

相关推荐
Jamesvalley1 分钟前
【Django】新增字段后兼容旧接口 This field is required
后端·python·django
JAVA学习通27 分钟前
JAVA多线程(8.0)
java·开发语言
Luck_ff081030 分钟前
【Python爬虫详解】第四篇:使用解析库提取网页数据——BeautifuSoup
开发语言·爬虫·python
学渣6765637 分钟前
什么时候使用Python 虚拟环境(venv)而不用conda
开发语言·python·conda
想睡hhh1 小时前
c++STL——stack、queue、priority_queue的模拟实现
开发语言·c++·stl
悲喜自渡7211 小时前
线性代数(一些别的应该关注的点)
python·线性代数·机器学习
小鹿鹿啊1 小时前
C语言编程--14.电话号码的字母组合
c语言·开发语言·算法
Sunlight_7771 小时前
第六章 QT基础:6、QT的Qt 时钟编程
开发语言·qt·命令模式
cloues break.1 小时前
C++初阶----模板初阶
java·开发语言·c++
wwww.wwww1 小时前
Qt软件开发-摄像头检测使用软件V1.1
开发语言·c++·qt