Closed chenxuuu closed 5 years ago
协议可能已经变化。我有空的时候再看一下。
大佬加油,我现在自己用笨办法获取的弹幕信息 坐等更新
with aiohttp.ClientSession() as s:
async with s.get('http://live.bilibili.com/' + str(self._roomId)) as r:
html = await r.text()
m = re.findall(r'ROOMID\s=\s(\d+)', html)
ROOMID = m[0]
self._roomId = int(ROOMID)
async with s.get(self._CIDInfoUrl + ROOMID) as r:
xml_string = '<root>' + await r.text() + '</root>'
dom = xml.dom.minidom.parseString(xml_string)
root = dom.documentElement
server = root.getElementsByTagName('server')
self._ChatHost = server[0].firstChild.data
你可以暂时把这段代码注释掉。应该是 html 页面结构变了。去掉以后不影响。
好像抓包抓到的数据包,规则都变掉了,我上次解码出来的东西和之前文章写的不太一样了 现在我获取弹幕和发送弹幕都是用的笨办法😂
不知道为什么运行一段时间就停了。
没有断线重连功能吗。。。我也是运行一段时间就停了
注释掉可以了,棒!
@chenxuuu 你说的笨方法,不会是一直从html里提然后去掉之前的吧😂
@fuyingdi 对啊,现在我用的还是这个方法,简单好用
@chenxuuu 可以,直接用你代码了
B站 Web 页面经常改, 从 Web 页面的 HTML 里面获取直播间信息并不是一个好办法.
最好的办法是从 Bilibili APP 的 API 里面来取得直播间信息, 为了兼容旧客户端, 客户端 API 在很长一段时间内都不会改动.
例如获取直播间信息的 API 是这样的
http://api.live.bilibili.com/AppRoom/index?room_id=3&platform=android
里面包含了房间的真实ID, 弹幕推送服务器地址, 端口(APP 的端口和 Web 上用的不一样)
直播站有关的其他 API 可以看 这里
由于用了 Retrofit, 看上面的注解就行了, 文档懒得写了
注释掉那段就可以跑起来了,有趣🌚
根据个人跟踪,破站平均每3天更新一次房间页代码,有时候一天更新3次都是正常事
好像ROOMID修改规则了。。。 话说能手动填不