其他的 API
网易云的
http://music.163.com/song/media/outer/url?id={music_id}.mp3 可以直接得到低音质音频文件
https://music.163.com/api/song/media?id={music_id} 另一个歌词 API
得到一个歌手的所有专辑的方法(用 lxml
+ requests
):
python
headers = {
"Host": "music.163.com",
"Referer": "https://music.163.com/",
"User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36",
}
def get_artist_albums(
aid: int, page_size: int = 100, offset: int = 0
) -> tuple[list, bool]:
"""
返回歌曲列表 和 一个表示是否还有更多的布尔值
"""
url = (
f"https://music.163.com/artist/album?id={aid}&limit={page_size}&offset={offset}"
)
with session.get(url, headers=headers) as resp:
html_str = resp.text
html = etree.fromstring(html_str, etree.HTMLParser())
elem = html.xpath('//*[@id="m-song-module"]')
assert elem, "Empty Response"
result = []
for li in elem[0]:
div, p1, p2 = [i for i in li]
img, a1, a2 = [i for i in div]
span = p2[0]
result.append(
{
"title": div.attrib["title"],
"cover": img.attrib["src"].split("?")[0],
"album_id": int(a2.attrib["data-res-id"]),
"release_date": span.text,
}
)
return result, bool(html.xpath('//*[@class="zbtn znxt"]'))
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
嗯这个函数是我闲得没事折腾歌词词云的时候弄的,结果因为歌词里面混了很多音乐元数据没法清干净, 再加上 jieba 分词疑似有点不够现代化 所以效果一般。
什么你很好奇?那我放几张()
酷狗的
不确定能不能用就是了
python
api_search = 'http://mobilecdn.kugou.com/api/v3/search/song?format=json&keyword={keyword}&page={page}&pagesize=20&showtype=1'
api_info = 'http://m.kugou.com/app/i/getSongInfo.php?cmd=playInfo&hash={music_hash}'
api_info_with_lrc = 'http://www.kugou.com/yy/index.php?r=play/getdata&hash={music_hash}'
1
2
3
2
3
Q 音的
不知道能不能用就是了
python
api_lrc = 'https://c.y.qq.com/lyric/fcgi-bin/fcg_query_lyric_new.fcg?g_tk=753738303&songmid={music_id}'
# headers: {
# 'Referer': 'https://y.qq.com/portal/player.html',
# 'Cookie': 'skey=@LVJPZmJUX; p',
# }
api_info = 'https://u.y.qq.com/cgi-bin/musicu.fcg?format=json&inCharset=utf8&outCharset=utf-8&data=%7b%22songinfo%22%3a%7b%22method%22%3a%22get_song_detail_yqq%22%2c%22param%22%3a%7b%22song_type%22%3a0%2c%22song_mid%22%3a%22{music_id}%22%7d%2c%22module%22%3a%22music.pf_song_detail_svr%22%7d%7d'
# 这里应该是一段json
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8