def save_music(url_list, name_list):
"""下载音乐"""
path = 'D:\\Music\\抖音'
# 如果不存在目录,创建目录
if not os.path.exists(path):
os.makedirs(path)
for i in range(1, len(url_list)):
name = name_list
music = requests.get(url=url_list, verify=False)
if music.status_code == 200:
with open('{}/{}.mp3'.format(path, name), 'wb') as f:
f.write(music.content)
print('{}:Download successful: {}.mp3'.format(i, name))
else:
print('下载歌曲失败')
domain
[Python] 纯文本查看复制代码
def do_main():
for i in range(1, 2):
music_list = get_music_list()
url_list, name_list = get_music_url(music_list)
save_music(url_list, name_list)