码迷,mamicode.com
首页 > 编程语言 > 详细

python API获取音乐链接,歌手信息........

时间:2021-06-06 19:17:40      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:lan   data   pen   ade   java   pytho   jpg   inpu   信息   

import requests
import re
from threading import Thread
from bs4 import BeautifulSoup
import openpyxl
import json
class MUSIC(Thread):
	def run(self):
	songname=input("请输入歌名:")
	da={
	‘input‘: songname,
	‘filter‘: ‘name‘,
	‘type‘: ‘kugou‘,
	‘page‘: ‘1‘
	}
	header={
	"user-agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3947.100 Safari/537.36",
	"x-requested-with":"XMLHttpRequest"
	}
	iic=[]
	# 发送请求,抓取信息
	res = requests.post("http://music.xionggd.com/",headers=header,data=da)
	respon=res.json()
	for i in range(0,len(respon[‘data‘])):
		link=respon[‘data‘][i][‘link‘]
		title=respon[‘data‘][i][‘title‘]
		author=respon[‘data‘][i][‘author‘]
		lrc=respon[‘data‘][i][‘lrc‘]
		url=respon[‘data‘][i][‘url‘]
		pic=respon[‘data‘][i][‘pic‘]
		print(i,‘歌手:‘+author,‘歌名:‘+title)

		j=int(input(‘请输入序列号:‘))
		link = respon[‘data‘][j][‘link‘]
		title = respon[‘data‘][j][‘title‘]
		author = respon[‘data‘][j][‘author‘]
		lrc = respon[‘data‘][j][‘lrc‘]
		url = respon[‘data‘][j][‘url‘]
		pic = respon[‘data‘][j][‘pic‘]
		lrc = re.sub(‘\r\n‘, ‘‘, lrc)
		lrc = lrc.replace(‘\ufeff‘, ‘‘)
		iic.append(lrc)
		word= "{name:‘"+title+"‘,artist:‘"+author+"‘,url:‘"+url+"‘,cover:‘"+pic+"‘,"+‘lrc:"‘+iic[0]+‘"},‘
		print(word)

if __name__ == ‘__main__‘:
    t=MUSIC()
    t.start()

https://mmtstock.imgix.net/photos/P1100475.jpg?q=85&w=2732&h=

python API获取音乐链接,歌手信息........

标签:lan   data   pen   ade   java   pytho   jpg   inpu   信息   

原文地址:https://www.cnblogs.com/weitongxue/p/14854669.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!