代码拉取完成,页面将自动刷新
import requests
singer = input("请输入歌手姓名:")
num = input("请输入你想下载的页数:")
url = "http://www.kuwo.cn/api/www/search/searchMusicBykeyWord?key={}&pn={}&rn=30&httpsStatus=1&reqId=3e4d1df0-1825-11eb-84d6-675fbe9cc944".format(singer, num)
headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36","csrf": "SIULN0H2OJG",
"Cookie": "_ga=GA1.2.2097782952.1603111711; _gid=GA1.2.1679275262.1603777785; Hm_lvt_cdb524f42f0ce19b169a8071123a4797=1603458868,1603523641,1603777785,1603782958; Hm_lpvt_cdb524f42f0ce19b169a8071123a4797=1603783110; kw_token=SIULN0H2OJG",
"Host": "www.kuwo.cn",
"Referer": "http://www.kuwo.cn/search/list?key=%E5%91%A8%E6%9D%B0%E4%BC%A6"
}
response = requests.get(url, headers=headers).json()
data = response["data"]["list"]
for i in data:
rid = i["rid"]
name = i["name"]
# print(rid,name)
new_url = "http://www.kuwo.cn/url?format=mp3&rid=" + str(
rid) + "&response=url&type=convert_url3&br=128kmp3&from=web&t=1603783380310&httpsStatus=1&reqId=3e4e5671-1825-11eb-84d6-675fbe9cc944"
res = requests.\
get(new_url).json()
result = requests.get(res["url"]).content
path = "酷我音乐\\" + name + ".mp3"
with open(path, "wb") as f:
f.write(result)
print("正在下载", name)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。