标签:生成 展示 imp personal crawl nal com self script
netcloud/
├── analyse
│
├── crawler
│
├── demo
│
├── login
│
├── test
│
└── util - source
netcloud是模块根目录
analyse:网易云音乐评论以及用户信息可视化分析的模块
crawler:网易云音乐评论爬虫模块
demo:一些demo
login:网易云音乐模块登录模块,提供了丰富的网易云api,包括音乐评论,专辑,歌手等等
test:测试模块
util:工具类模块,其中也包括了source目录,主要存放一些资源文件
from netcloud.crawler.Crawler import NetCloudCrawler
singer_name = "林俊杰"
song_name = "豆浆油条"
nc_crawler = NetCloudCrawler(song_name = song_name,singer_name = singer_name)
# 保存歌手的全部热门评论
nc_crawler.save_singer_all_hot_comments_to_file()
# 使用多线程(20个线程)保存歌曲的全部评论
nc_crawler.save_all_comments_to_file_by_multi_threading(20)
2.对于歌曲的评论文件以及评论用户进行可视化分析
from netcloud.analyse.Analyse import NetCloudAnalyse
singer_name = "王力宏"
song_name = "需要人陪"
nc_analyse = NetCloudAnalyse(song_name = song_name,singer_name = singer_name)
# 多线程抓取歌曲评论的全部用户相关信息并保存到磁盘
nc_analyse.save_all_users_info_to_file_by_multi_threading()
# 进行核心可视化分析,包括用户属性分布(年龄,地区,性别等)以及评论时间,关键词分布等),
# 生成的html文件可以在浏览器打开查看
nc_analyse.core_visual_analyse()
3.模拟登录网易云音乐,并尝试一些api
from netcloud.login.Login import NetCloudLogin
# 模拟登录,如果不传任何参数,则表示从config.xml文件加载登录信息(用户名,密码等)
# 配置文件的默认路径是:当前登录用户home目录/.NetCloud/config/config.xml
nc_login = NetCloudLogin()
# 也可以显式传入用户名和密码等登录信息
#nc_login = NetCloudLogin(phone="xxxxxxxxxxx",password="xxxxxxx",email="xxxxx",rememberLogin=True)
# 打印登录用户的朋友动态,结果以json格式展示
print(nc_login.get_friends_event().json())
# 打印自身用户id
print(nc_login.get_self_id())
# 打印自己收藏的专辑(结果太长,这里略过)
print(nc_login.get_self_record().json())
# 单线程下载歌单中的全部歌曲到本地
nc_login.download_play_list_songs(2431814627,limit=1000)
# 打印自己的前10条fans信息
print(nc_login.get_self_fans(offset=0,limit=10).json())
from netcloud.login.Printer import NetCloudPrinter
# 同上,可以不传参数从配置文件加载登录信息
# 或者也可以显式传入登录参数
nc_printer = NetCloudPrinter()
# 格式化打印搜索api搜索歌手`韩红`的结果
nc_printer.pretty_print_search_singer(search_singer_name="韩红")
‘‘‘
2019-01-15 02:56:23,416 - Printer.py[line:246] - INFO: Your search singer name is:韩红
2019-01-15 02:56:23,417 - Printer.py[line:249] - INFO: Here is your search result(total 1):
2019-01-15 02:56:23,417 - Printer.py[line:251] - INFO: -------------------- search result 1 --------------------
2019-01-15 02:56:23,417 - Printer.py[line:253] - INFO: singer name:韩红
2019-01-15 02:56:23,418 - Printer.py[line:255] - INFO: alias:
2019-01-15 02:56:23,418 - Printer.py[line:259] - INFO:
singer id:7891
2019-01-15 02:56:23,418 - Printer.py[line:261] - INFO: singer image url:http://p2.music.126.net/Se3mLHw_oKufAnG7VCka_g==/109951163096672305.jpg
2019-01-15 02:56:23,418 - Printer.py[line:263] - INFO: singer mv count:20
2019-01-15 02:56:23,418 - Printer.py[line:265] - INFO: singer album count:43
‘‘‘
# 格式化打印自己的信息
nc_printer.pretty_print_self_info()
‘‘‘
2019-01-15 03:33:21,658 - Printer.py[line:57] - INFO: Hello,Lyrichu!
Here is your personal info:
2019-01-15 03:33:21,659 - Printer.py[line:74] - INFO: avatarUrl:http://p2.music.126.net/OkEDo-a_rHCC1zEDbg7dYg==/8003345140341032.jpg
signature:热爱生活,热爱音乐!
nickname:Lyrichu
userName:0_m15527594439@163.com
province_id:420000
birthday:1995-02-12
description:
gender:male
userId:44818930
cellphone:xxxxxxx
email:xxxxxxxx@163.com
‘‘‘
网易云音乐综合爬虫python库NetCloud v1版本发布
标签:生成 展示 imp personal crawl nal com self script
原文地址:https://www.cnblogs.com/lyrichu/p/10299441.html