BiliBili系列(二):个人历史数据爬取与分析 |
您所在的位置:网站首页 › bilibili怎么看观看历史 › BiliBili系列(二):个人历史数据爬取与分析 |
文章目录
一、使用cookie进行登录二、个人历史数据爬取三、数据清洗四、数据分析
完整代码链接:查看 一、使用cookie进行登录我们已经进行了模拟用户登录并获取了cookie,所以在爬取的时候直接使用cookie就能实现登录了。 二、个人历史数据爬取最后数据呈现: get_personal_history 针对以下页面: 代码链接:查看 代码链接:查看 四、数据分析 import pandas as pd from wordcloud import WordCloud import numpy as np from PIL import Image import matplotlib.pyplot as plt data = pd.read_csv('personal_history/清理后的个人历史数据(非直播).csv',1、视频的标签分析 parse_dates=['时间']) labels = data['标签'].sum().split(' ') labels_dict = {} for label in labels: labels_dict[label] = labels_dict.get(label, 0) + 1 background = np.array(Image.open('background.jpeg')) word_cloud = WordCloud( font_path="simhei.ttf", width=1200, #词云图宽 height=1000, #词云图高 background_color='white', #词云图背景颜色 mask=background, max_words= 80, max_font_size= 70, random_state=1).fit_words(labels_dict) plt.figure(figsize=(8,8)) plt.imshow(word_cloud) plt.axis('off') plt.show()2、每日浏览次数分析 plt.rcParams['font.sans-serif']=['SimHei'] plt.figure(figsize=(8,6)) data['时间'].apply(lambda x : x.date()).value_counts().plot() plt.title('每日浏览次数统计') plt.grid() plt.show()
|
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |