赞
踩
B站的宣传片《后浪》引起了很大反响,从各方面的了解,目前观众们的反馈,负面的情绪比较多,那么真的是这样吗?因此想通过爬取评论,利用snownlp,看下数据下真实的样子!
一、爬取
去掉后可以获取到json格式信息,方便信息提取
找到评论所在位置提取,也可以提取到其他需要的信息
# -*- coding: utf-8 -*- """ Created on Wed May 13 11:52:11 2020 @author: Administrator """ import requests import time import json def get_html(n): headers={ 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36', "cookie": "_uuid=3BEB537F-A423-3339-ADAE-B9F98CE2F1A614498infoc; buvid3=E8D76FBA-069D-49DC-8F88-787C9513FEB9190975infoc; LIVE_BUVID=AUTO2815753467172931; CURRENT_FNVAL=16; stardustvideo=1; rpdid=|(u)~km)Rm)l0J'ul~lJRY~lk; laboratory=1-1; sid=j6rx3drb; CURRENT_QUALITY=32; PVID=2; bfe_id=61a513175dc1ae8854a560f6b82b37af", 'Referer': 'https://www.bilibili.com/video/BV1FV411d7u7?from=search&seid=9323669094129958607', 'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8', } url = 'https://api.bilibili.com/x/v2/reply?&pn='+str(n)+'&type=1&oid=412935552&sort=2&_=1589337097696' r = requests.get(url,headers=headers
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。