bilibili弹幕爬虫记录 8/7/2020

获取aid:①python BV转AV (有一定错误风险)

代码如下:

table=’fZodR9XQDSUm21yCkr6zBqiveYah8bt4xsWpHnJE7jL5VG3guMTKNPAwcF’
tr={}
for i in range(58):
tr[table[i]]=i
s=[11,10,3,8,4,6]
xor=177451812
add=8728348608

def dec(x):
r=0
for i in range(6):
r+=tr[x[s[i]]]*58*i
return (r-add)^xor

def enc(x):
x=(x^xor)+add
r=list(‘BV1 4 1 7 ‘)
for i in range(6):
r[s[i]]=table[x//58**i%58]
return ”.join(r)

获取历史弹幕时间列表:https://api.bilibili.com/x/v2/dm/history/index?type=1&oid=220780973&month=2020-08

获取现在的弹幕:https://api.bilibili.com/x/v1/dm/list.so?oid=220780973

获取历史弹幕:https://api.bilibili.com/x/v2/dm/history?type=1&oid=220780973&date=2020-08-06

获取OID:①https://api.bilibili.com/x/player/pagelist?aidb=视频的av号

②https://api.bilibili.com/x/player/pagelist?bvid=视频的bv号&jsonp=jsonp

其中的cid属性就是视频的oid

其他的参考链接:https://www.bilibili.com/read/cv5187469/?from=readlist

https://blog.csdn.net/sinat_36461778/article/details/88880314