爬虫功能,批量输出歌曲的歌词
使用方法:
pip install cloudmusic
pip install re
pip install python
请先确保自己已经安装了以上的库
首先输出你要的查询的歌曲
其次输出你要打印的数量(默认为5首)
注意:由于本人技术原因,输出的歌词前面带有出现的时间点,需要用到正则表达式来提取,(但是暂时不会),所以请自行处理!
import cloudmusic
import re
def remove_stop_words(f):
stop_words = ['作词', '作曲', '编曲', 'Arranger', '录音', '混音', '人声', 'Vocal', '弦乐', 'Keyboard', '键盘', '编辑', '助理', 'Assistants', 'Mixing', 'Editing', 'Recording', '音乐', '制作', 'Producer', '发行', 'produced', 'and', 'distributed','合作人:','/母带处理:','专辑封面设计:','/母带处理:',':',' :']
for stop_word in stop_words:
f = f.replace(stop_word, '')
return f
content =input('Please enter music name ')
number = input('Please enter the number of result')
songs = cloudmusic.search(content,number)
for single_song in songs:
song = cloudmusic.getMusic(single_song.id)
print('+++++++++++++++{}歌词+++++++++++++++'.format(song.name))
print('++++++++++++++++++++++++++++++++++++++++++')
lyrics = song.getLyrics()
print(remove_stop_words(lyrics[0]))