小伙子不讲武德,竟用Python爬取了B站上1.4w条马老师视频数据来分析
点击上方“AI算法与图像处理”,选择加"星标"或“置顶”
重磅干货,第一时间送达
https://api.bilibili.com/x/web-interface/web/channel/multiple/list?channel_id=3503796&sort_type=hot&page_size=30
offest
从解析上一个url的json中获取,如如下图所示。
def get_data(url,headers):
data_m = pd.DataFrame(columns=['id','name','view_count','like_count','duration','author_name','author_id','bvid'])
html = requests.get(url,headers=headers).content
data = json.loads(html.decode('utf-8'))
offset = data['data']['offset']
print(offset)
for j in range(30):
data_m = data_m.append({'id':data['data']['list'][j]['id'],'name':data['data']['list'][j]['name'],
'view_count':data['data']['list'][j]['view_count'],'like_count':data['data']['list'][j]['like_count'],
'duration':data['data']['list'][j]['duration'],'author_name':data['data']['list'][j]['author_name'],
'author_id':data['data']['list'][j]['author_id'],'bvid':data['data']['list'][j]['bvid']},ignore_index=True)
return(offset,data_m)
# 绘制词云图
stylecloud.gen_stylecloud(text=' '.join(text1),
collocations=False,
font_path=r'C:\Windows\Fonts\msyh.ttc',
icon_name='fas fa-play-circle',
size=653,
output_name='马保国词云图.png')
Image(filename='马保国词云图.png')
— 完 —
下载1:leetcode 开源书
在「AI算法与图像处理」公众号后台回复:leetcode,即可下载。每题都 runtime beats 100% 的开源好书,你值得拥有!
下载2 CVPR2020
在「AI算法与图像处理」公众号后台回复:CVPR2020,即可下载1467篇CVPR 2020论文 个人微信(如果没有备注不拉群!) 请注明:地区+学校/企业+研究方向+昵称
觉得不错就点亮在看吧
?
评论