littlecodersh / danmu Goto Github PK
View Code? Open in Web Editor NEWPython 弹幕包 A live danmu package for python
License: Other
Python 弹幕包 A live danmu package for python
License: Other
import time, sys
from danmu import DanMuClient
def pp(msg):
print(msg.encode(sys.stdin.encoding, 'ignore').
decode(sys.stdin.encoding))
#dmc = DanMuClient('https://www.douyu.com/32892')
#dmc = DanMuClient('https://live.bilibili.com/324')
dmc = DanMuClient('https://www.panda.tv/66666')
if not dmc.isValid(): print('Url not valid')
@dmc.danmu
def danmu_fn(msg):
pp('[%s] %s' % (msg['NickName'], msg['Content']))
@dmc.gift
def gift_fn(msg):
pp('[%s] sent a gift!' % msg['NickName'])
@dmc.other
def other_fn(msg):
pp('Other message received')
dmc.start(blockThread=True)
清楼主试试网易cc
python test.py
success
但是爬不到东西
昨天晚上还能爬到东西的,同样的设置早上就爬不到了 ,换了好几个正在直播的页面都爬不到
import time
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
from danmu import DanMuClient
def pp(msg):
print(msg.encode(sys.stdin.encoding, 'ignore').
decode(sys.stdin.encoding))
dmc = DanMuClient('https://www.douyu.com/778895')
if not dmc.isValid(): print('Url not valid')
else: print ('success')
@dmc.danmu
def danmu_fn(msg):
pp('[%s] %s' % (msg['NickName'], msg['Content']))
with open ('danmu.txt','a') as f:
# f.write('%s [%s] %s \n' % (time.strftime("%a %b %d %H:%M:%S %Y", time.localtime()) ,msg['NickName'], msg['Content'])
f.write('%s \n' %(msg['Content']))
@dmc.gift
def gift_fn(msg):
pp('[%s] sent a gift!' % content['NickName'])
@dmc.other
def other_fn(msg):
pp('Other message received')
dmc.start(blockThread = True)
这里不回答python的基础问题,只做意见收集用途。
所有意见我都会及时回复的~
报bug记得另开issue。
斗鱼可以更改用户名,但是获取弹幕的时候没有获取uid
我设置为false时debug _start()方法的断点没走,程序没有输出是什么情况
如题。
http://m.panda.tv/66666
这个API似乎不再可用了
http://www.panda.tv/ajax_chatroom?roomid=%s&_=%s'%(roomId, str(int(time.time())))
fangs-mac:danmu fang$ python3 a.py
^CTraceback (most recent call last):
File "a.py", line 24, in
dmc.start(blockThread = True)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/danmu/init.py", line 55, in start
self.__client.start()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/danmu/Abstract.py", line 29, in start
time.sleep(self.anchorStatusRescanTime)
KeyboardInterrupt
例如这种房间地址:https://www.douyu.com/topic/nzds?rid=5395900
需要增加正则匹配 room_id = re.findall(r'rid=(\d{1,7})', url)[0]
如题
这个是官方行为还是bug呢?
获取弹幕的时候,如果有用户发送礼物会报错
如果项目里面也使用了logging模块的话,输出信息会变为2条
注释from .log import set_logging恢复正常
试了好几个好像只剩douyu能用了。。。
i find a problem that when using DanmuClient, some new douyu room url seems not wroking for the same version client, ex: 'https://www.douyu.com/65000'
but some other douyu_url i crawled before is also useful, did someone has the same problem here ?
测试b站的时候 发现网页里面不能直接获取到ROOMID了 但感谢解析的过程
前几天是好的,这几天出现这种情况
λ python pilirun.py
Traceback (most recent call last):
File "pilirun.py", line 3, in
from danmu import DanMuClient
ModuleNotFoundError: No module named 'danmu'
用的anaconda带的python,装的时候是3.5版本,这两天看了好像自动升级到3.6版本了,是不是因为3.6不兼容的原因?
@tempdban
兄弟,我在想这个包应该做成什么样子给用户使用。
没找到什么好的想法,有什么建议吗?
想问一下大佬们,douyu这些是平台给了接口才能访问到的吗,如果平台没有给接口该如何拿到数据?
如果我正在爬取斗鱼的弹幕信息,我现在要立刻停止怎么操作啊?
Traceback (most recent call last):
File "D:/Users/yidian/PycharmProjects/trans/danmu.py", line 3, in
from danmu import DanMuClient;
File "D:\Users\yidian\PycharmProjects\trans\danmu.py", line 3, in
from danmu import DanMuClient;
ImportError: cannot import name 'DanMuClient'
问题描述:
斗鱼,全民,熊猫,战旗这4个平台测试了有50个主播,都只能截获到普通danmu消息,礼物的截获不到,求大神指教
系统:
centos6.5
代码:
@dmc.danmu
def danmu_fn(msg):
payload = {
"star_id": star_id,
"text": msg['Content'],
"type": "danmu",
"plat": plat
}
r = requests.get("http://localhost:9203/save", params=payload)
@dmc.gift
def gift_fn(msg):
pp('[%s] sent a gift!' % content['NickName'])
payload = {
"star_id": star_id,
"text": "gift",
"type": "gift",
"plat": plat
}
r = requests.get("http://localhost:9203/save", params=payload)
@dmc.other
def other_fn(msg):
pp('Other message received')
dmc.start(blockThread = True)
如题.
比如我安装了mpv,youtube-dl
运行 python run.py 后,同时运行 mpv https://www.douyu.com/32892 来打开播放器观看在线视频
谢谢楼主提供的好软件
如题,不显示弹幕了。。。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.