import requests
import json
import urllib
.request
headers
={'Host':'music.bbbbbb.me',
'User-Agent':'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:65.0) Gecko/20100101 Firefox/65.0',
'Accept':'application/json, text/javascript, */*; q=0.01',
'Accept-Language':'zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2',
'Accept-Encoding':'gzip, deflate',
'Referer':'http://music.bbbbbb.me/',
'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8',
'X-Requested-With':'XMLHttpRequest',
'Content-Length':'47',
'Connection':'keep-alive',
'Pragma':'no-cache',
'Cache-Control':'no-cache'}
def search_Music(mname
):
global headers
data
={'input':mname
,'filter':'name','type':'netease','page':'1'}
url
= 'http://music.bbbbbb.me/'
wbdata
= requests
.post
(url
,headers
=headers
,data
=data
).text
data
= json
.loads
(wbdata
)
return data
def ShowList(data
):
i
=1
for n
in data
['data']:
author
= n
['author']
url
= n
['url']
print("编号:",i
,"歌手:",author
,"下载地址:",url
)
i
=i
+1
def DownLoad(data
,mname
):
Number
=int(input("请输入要下载的编号"))
url
=data
['data'][Number
-1]['url']
singer
=data
['data'][Number
-1]['author']
base
="F:/酷狗歌曲下载/"
MusicName
=singer
+" - "+mname
+".mp3"
filepath
=base
+MusicName
urllib
.request
.urlretrieve
(url
,filepath
)
print("下载完成")
def main():
mname
=input("请输入要下载的歌曲:")
data
=search_Music
(mname
)
ShowList
(data
)
DownLoad
(data
,mname
)
main
()
转载请注明原文地址: https://mac.8miu.com/read-497319.html