通过 bv 号获取 b 站视频弹幕
作者:
孙庚辛 | 来源:发表于
2020-05-19 20:52 被阅读0次import requests
import json
import re
def get_cid(bv):
url = 'https://api.bilibili.com/x/player/pagelist?bvid=%s' % bv
res = requests.get(url)
res_text = res.text
res_dict = json.loads(res_text)
cid = res_dict['data'][0]['cid']
return cid
def get_bullet_chat(cid):
url = 'https://api.bilibili.com/x/v1/dm/list.so?oid=%s' % cid
res = requests.get(url)
res.xml = res.content.decode('utf-8')
patt = re.compile('<d.*?>(.*?)</d>')
bullet_list = patt.findall(res.xml)
return bullet_list
def wold_count(bullent):
bullent = str(bullent)
print(bullent)
if __name__ == '__main__':
bv = 'BV1Jz411b7zG'
cid = get_cid(bv)
bullent = get_bullet_chat(cid)
wold_count(bullent)
本文标题:通过 bv 号获取 b 站视频弹幕
本文链接:https://www.haomeiwen.com/subject/gwyiohtx.html
网友评论