本文主要是介绍网易云爬虫系列-取得歌曲歌词,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
感谢:https://github.com/p697
注意本爬虫需要使用
pip install cloudmusic
安装库
提醒:由于本人技术原因(菜鸡不会正则表达式)所以输出的结果中会包含每一句歌词和歌词出现的时间,请各位大佬自行处理!
import cloudmusic
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
song = cloudmusic.getMusic(1449339372) #取得歌曲id
print(song.name) #输出歌曲id
lyrics = song.getLyrics() #取得歌词,列表形式
print(remove_stop_words(lyrics[0])) #取出歌词
花粥,民谣女流氓,嗯,我喜欢!
这篇关于网易云爬虫系列-取得歌曲歌词的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!