资源简介
python下载音乐源代码,输入你想要下载的歌手的名字,你就可以下载
代码片段和文件信息
import requests
import re
import json
import os
def get_name(singer):
url = ‘https://c.y.qq.com/soso/fcgi-bin/client_search_cp‘
params = {
‘catZhida‘: ‘1‘
‘w‘: singer
}
headers = {
‘referer‘: ‘https://y.qq.com/portal/search.html‘
‘user-agent‘: ‘Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML like Gecko) Chrome/66.0.3359.139 Safari/537.36‘
}
html = requests.get(urlheaders=headersparams=params).text
content = re.compile(‘callback\((.*)\)‘).findall(html)[0]
content = json.loads(content)
data = content.get(‘data‘)
song = data.get(‘song‘)
lists = song.get(‘list‘)
name = []
for list in lists:
singer = list.get(‘singer‘)[0].get(‘mid‘)
name.append(singer)
name = name[0]
return name
def get_html(namesinger):
url = ‘https://c.y.qq.com/v8/fcg-bin/fcg_v8_singer_track_cp.fcg‘
params = {
‘singermid‘: name
‘order‘: ‘listen‘
‘begin‘: ‘0‘
‘num‘: ‘10‘
}
headers = {
‘referer‘: ‘https://y.qq.com/n/yqq/singer/003aQYLo2x8izP.html‘
‘user-agent‘: ‘Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML like Gecko) Chrome/66.0.3359.139 Safari/537.36‘
}
html = requests.get(urlheaders=headersparams=params).text
return html
def get_music(vkeysongnamefilenamesinger):
if vkey and songname:
url3 = ‘http://dl.stream.qqmusic.qq.com/‘ + filename + ‘?vkey=‘ + vkey + ‘&guid=7133372870&uin=0&fromtag=66‘
headers = {
‘referer‘: ‘https://y.qq.com/n/yqq/singer/003aQYLo2x8izP.html‘
‘user-agent‘: ‘Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML like Gecko) Chrome/66.0.3359.139 Safari/537.36‘
}
music = requests.get(url3headers=headers).content
dir = singer
if not os.path.exists(dir):
os.mkdir(dir)
with open(dir+‘/‘+songname+‘.m4a‘‘wb‘) as f:
f.write(music)
print(songname‘__‘singer)
d
- 上一篇:用python实现基于情感词典的情感分析
- 下一篇:music.py
相关资源
- python+ selenium教程
- PycURL(Windows7/Win32)Python2.7安装包 P
- 英文原版-Scientific Computing with Python
- 7.图像风格迁移 基于深度学习 pyt
- 基于Python的学生管理系统
- A Byte of Python(简明Python教程)(第
- Python实例174946
- Python 人脸识别
- Python 人事管理系统
- 基于python-flask的个人博客系统
- 计算机视觉应用开发流程
- python 调用sftp断点续传文件
- python socket游戏
- 基于Python爬虫爬取天气预报信息
- python函数编程和讲解
- Python开发的个人博客
- 基于python的三层神经网络模型搭建
- python实现自动操作windows应用
- python人脸识别(opencv)
- python 绘图(方形、线条、圆形)
- python疫情卡UN管控
- python 连连看小游戏源码
- 基于PyQt5的视频播放器设计
- 一个简单的python爬虫
- csv文件行列转换python实现代码
- Python操作Mysql教程手册
- Python Machine Learning Case Studies
- python获取硬件信息
- 量化交易(附python常见函数的使用方
- python 名字用字排行
评论
共有 条评论