抖音直播间(web版)弹幕抓取

This commit is contained in:
耿伦伦
2021-11-28 00:05:59 +08:00
commit 4ea37b0a65
21 changed files with 7215 additions and 0 deletions

0
scripts/__init__.py Normal file
View File

37
scripts/watcher.py Normal file
View File

@ -0,0 +1,37 @@
import time
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
from messages.utils import unpackMsgBin
class Watcher:
DIRECTORY_TO_WATCH = ""
def __init__(self, directory):
self.observer = Observer()
self.DIRECTORY_TO_WATCH = directory
def run(self):
event_handler = Handler()
self.observer.schedule(event_handler, self.DIRECTORY_TO_WATCH, recursive=True)
self.observer.start()
try:
while True:
time.sleep(5)
except:
self.observer.stop()
self.observer.join()
class Handler(FileSystemEventHandler):
@staticmethod
def on_any_event(event):
if event.is_directory:
return None
elif event.event_type == 'created':
unpackMsgBin(event.src_path)