|
|
@ -68,6 +68,8 @@ def the_Any_music():
|
|
|
|
list_json = json.loads(req.text[n:])
|
|
|
|
list_json = json.loads(req.text[n:])
|
|
|
|
total = list_json['data']['total']
|
|
|
|
total = list_json['data']['total']
|
|
|
|
list_num = total // 20 # 获取歌曲总页数进行不同页数爬取
|
|
|
|
list_num = total // 20 # 获取歌曲总页数进行不同页数爬取
|
|
|
|
|
|
|
|
if list_num == 0:
|
|
|
|
|
|
|
|
list_num =1
|
|
|
|
print(f"页数总数为{list_num}")
|
|
|
|
print(f"页数总数为{list_num}")
|
|
|
|
num = input("输入你想查看得页数:")
|
|
|
|
num = input("输入你想查看得页数:")
|
|
|
|
list_url = "http://mobilecdn.kugou.com/api/v3/search/song?format=json&keyword=" + song_name + "&page=" + str(num)
|
|
|
|
list_url = "http://mobilecdn.kugou.com/api/v3/search/song?format=json&keyword=" + song_name + "&page=" + str(num)
|
|
|
@ -85,14 +87,15 @@ def the_Any_music():
|
|
|
|
for x in list_json['data']['info']:
|
|
|
|
for x in list_json['data']['info']:
|
|
|
|
if y == int(song_num):
|
|
|
|
if y == int(song_num):
|
|
|
|
song_url = song_url + x.get("hash") + "&album_id=" + str(x.get('album_id'))
|
|
|
|
song_url = song_url + x.get("hash") + "&album_id=" + str(x.get('album_id'))
|
|
|
|
|
|
|
|
# print(song_url)
|
|
|
|
y = y + 1
|
|
|
|
y = y + 1
|
|
|
|
# print(song_url)
|
|
|
|
# print(song_url)2
|
|
|
|
song_req = requests.get(url=song_url, headers=headers)
|
|
|
|
song_req = requests.get(url=song_url, headers=headers)
|
|
|
|
song_json = json.loads(song_req.text)
|
|
|
|
song_json = json.loads(song_req.text)
|
|
|
|
# print(song_json)
|
|
|
|
# print(song_json)
|
|
|
|
song_url1 = song_json['data'].get('play_url')
|
|
|
|
song_url1 = song_json['data'].get('play_url')
|
|
|
|
song_req1 = requests.get(url=song_url1, headers=headers)
|
|
|
|
song_req1 = requests.get(url=song_url1, headers=headers)
|
|
|
|
with open(f'd:/PythonProject/music/{song_json["data"].get("audio_name")}.mp3', 'wb') as f:
|
|
|
|
with open(f'./music/{song_json["data"].get("audio_name")}.mp3', 'wb') as f:
|
|
|
|
f.write(song_req1.content)
|
|
|
|
f.write(song_req1.content)
|
|
|
|
f.close()
|
|
|
|
f.close()
|
|
|
|
song_req1.close()
|
|
|
|
song_req1.close()
|
|
|
@ -111,4 +114,4 @@ if feature_option == 1:
|
|
|
|
elif feature_option == 2:
|
|
|
|
elif feature_option == 2:
|
|
|
|
the_Any_music()
|
|
|
|
the_Any_music()
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
exit()
|
|
|
|
exit()
|