网易音乐下载和随机音乐推荐api


def download(song_id,text):
    try:
        url = 'http://music.163.com/song/media/outer/url?id=' + str(song_id)
        response = requests.get(url)
        content = response.content
        save_(content,text)
    except Exception as e:
        print('网易下载模块出错,请检查相关问题\n'+str(e))
def save_(content,text):
    try:
        path = os.path.dirname(os.path.abspath("__file__"))+('\music\\'+text+'.mp3')
        with open(path,mode='wb')as f:
            f.write(content)
    except Exception as e:
        print('保存文件出错,请检查相关模块\n'+str(e))

https://api.uomg.com/api/rand.music?format=json 这是随机推荐的音乐