lyyyuna / bilibili_danmu

B 站直播弹幕姬 Python 版
236 stars 47 forks source link

正在进入房间。。。 #7

Closed chenxuuu closed 5 years ago

chenxuuu commented 6 years ago

好像ROOMID修改规则了。。。 话说能手动填不

lyyyuna commented 6 years ago

协议可能已经变化。我有空的时候再看一下。

chenxuuu commented 6 years ago

大佬加油,我现在自己用笨办法获取的弹幕信息 坐等更新

lyyyuna commented 6 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 commented 6 years ago

好像抓包抓到的数据包,规则都变掉了,我上次解码出来的东西和之前文章写的不太一样了 现在我获取弹幕和发送弹幕都是用的笨办法😂

selfler commented 6 years ago

不知道为什么运行一段时间就停了。

Dawnnnnnn commented 6 years ago

没有断线重连功能吗。。。我也是运行一段时间就停了

Napic commented 6 years ago

注释掉可以了,棒!

fuyingdi commented 6 years ago

@chenxuuu 你说的笨方法,不会是一直从html里提然后去掉之前的吧😂

chenxuuu commented 6 years ago

@fuyingdi 对啊,现在我用的还是这个方法,简单好用

fuyingdi commented 6 years ago

@chenxuuu 可以,直接用你代码了

czp3009 commented 6 years ago

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, 看上面的注解就行了, 文档懒得写了

taseikyo commented 5 years ago

注释掉那段就可以跑起来了,有趣🌚

shugen002 commented 5 years ago

根据个人跟踪,破站平均每3天更新一次房间页代码,有时候一天更新3次都是正常事