网易音乐下载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))
上一篇:mybatis-plus 团队新作 mybatis-mate 轻松搞定数据权限


下一篇:设计模式之---原型模式