准备工作
歌单分享的url地址
代码实现
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']])