B站的弹幕的api是:"https://api.bilibili.com/x/v1/dm/list.so?oid=26495963
oid是视频的id
这个api用谷歌的开发者工具是看不到内容的,建议都用火狐来 找api
from selenium import webdriver
from lxml import etree
import requests
#这个是 B站弹幕爬取
url="https://api.bilibili.com/x/v1/dm/list.so?oid=26495963"
a={
"cid":26495965} #cid=oid
driver=webdriver.PhantomJS(executable_path=r'D:\ysc桌面\Desktop\phantomjs-2.1.1-windows\bin\phantomjs.exe')
driver.get(url)
response=requests.get(url)
print(type(driver.page_source)) #字符串
print(type(response.content)) #是二

本文介绍了如何利用selenium爬取B站的弹幕数据,通过解析视频ID(oid)调用API获取弹幕信息。由于谷歌开发者工具无法查看该API内容,推荐使用火狐浏览器进行API的查找和调试。最终目的是制作出具有代表性的弹幕词云图。
最低0.47元/天 解锁文章
72

被折叠的 条评论
为什么被折叠?



