diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..76159c2 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,13 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Python: 当前文件", + "type": "python", + "request": "launch", + "program": "${file}", + "console": "integratedTerminal", + "args": ["https://live.douyin.com/162574996168"] + } + ] +} \ No newline at end of file diff --git a/messages/__pycache__/base.cpython-39.pyc b/messages/__pycache__/base.cpython-39.pyc index 18da088..ac480e6 100644 Binary files a/messages/__pycache__/base.cpython-39.pyc and b/messages/__pycache__/base.cpython-39.pyc differ diff --git a/messages/__pycache__/roomuserseq.cpython-39.pyc b/messages/__pycache__/roomuserseq.cpython-39.pyc index b665d8c..3eac0d5 100644 Binary files a/messages/__pycache__/roomuserseq.cpython-39.pyc and b/messages/__pycache__/roomuserseq.cpython-39.pyc differ diff --git a/messages/__pycache__/utils.cpython-39.pyc b/messages/__pycache__/utils.cpython-39.pyc index 821dbb3..b31cddc 100644 Binary files a/messages/__pycache__/utils.cpython-39.pyc and b/messages/__pycache__/utils.cpython-39.pyc differ diff --git a/messages/base.py b/messages/base.py index 4942dc2..f881283 100644 --- a/messages/base.py +++ b/messages/base.py @@ -59,6 +59,8 @@ class Base: except Exception as e: print(self.instance.common.method + ' persists error') print(traceback.format_exc()) + finally: + store.close() def __str__(self): pass diff --git a/messages/roomuserseq.py b/messages/roomuserseq.py index 25115c9..d7b4c4b 100644 --- a/messages/roomuserseq.py +++ b/messages/roomuserseq.py @@ -16,4 +16,4 @@ class RoomUserSeqMessage(Base): return self.instance.totalUserStr def __str__(self): - return time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + '【观看人数】' + self.format_content() \ No newline at end of file + return time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + '【观看人数】' + '当前在线:' + str(self.instance.total) + ',历史总计:' + self.format_content() \ No newline at end of file diff --git a/scripts/__pycache__/watcher.cpython-39.pyc b/scripts/__pycache__/watcher.cpython-39.pyc index 2e029f8..e7b167e 100644 Binary files a/scripts/__pycache__/watcher.cpython-39.pyc and b/scripts/__pycache__/watcher.cpython-39.pyc differ diff --git a/scripts/__pycache__/webdriver.cpython-39.pyc b/scripts/__pycache__/webdriver.cpython-39.pyc index d5278fe..eb22349 100644 Binary files a/scripts/__pycache__/webdriver.cpython-39.pyc and b/scripts/__pycache__/webdriver.cpython-39.pyc differ diff --git a/scripts/watcher.py b/scripts/watcher.py index 5623741..5c4beb6 100644 --- a/scripts/watcher.py +++ b/scripts/watcher.py @@ -1,4 +1,3 @@ -import time import concurrent.futures import queue diff --git a/scripts/webdriver.py b/scripts/webdriver.py index 9a49a00..6aeb69a 100644 --- a/scripts/webdriver.py +++ b/scripts/webdriver.py @@ -15,7 +15,7 @@ from store.mongo import MongoStore def go(url): chrome_options = Options() chrome_options.add_argument('--proxy-server=%s' % config()['webdriver']['proxy']) - # chrome_options.add_argument('--headless') + chrome_options.add_argument('--headless') proxy = Proxy() proxy.proxy_type = ProxyType.MANUAL @@ -52,6 +52,7 @@ def go(url): 'admin_user_ids': roomInfo['room']['admin_user_ids'], 'owner': roomInfo['room']['owner'] }) + store.close() wait.until(presence_of_element_located((By.CLASS_NAME, "oSu9Aw19"))) \ No newline at end of file diff --git a/store/__pycache__/mongo.cpython-39.pyc b/store/__pycache__/mongo.cpython-39.pyc index 84ea613..7e2817f 100644 Binary files a/store/__pycache__/mongo.cpython-39.pyc and b/store/__pycache__/mongo.cpython-39.pyc differ diff --git a/store/mongo.py b/store/mongo.py index df85009..52116ed 100644 --- a/store/mongo.py +++ b/store/mongo.py @@ -7,6 +7,9 @@ class MongoStore: self.client = pymongo.MongoClient(config()['mongo']['uri']) self.db = self.client[config()['mongo']['dbname']] + def close(self): + self.client.close() + def set_collection(self, collection): self.collection = self.db[collection]