1 Star 1 Fork 0

杨冠2002/酷我音乐爬虫

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
爬取酷我音乐.py 1.39 KB
一键复制 编辑 原始数据 按行查看 历史
Your Name 提交于 2021-01-03 15:42 . 酷我音乐爬虫
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)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/yangguan2002/kuwo-music-crawler.git
git@gitee.com:yangguan2002/kuwo-music-crawler.git
yangguan2002
kuwo-music-crawler
酷我音乐爬虫
master

搜索帮助