close mongo connection
This commit is contained in:
parent
481c2f8b6b
commit
d61800b755
13
.vscode/launch.json
vendored
Normal file
13
.vscode/launch.json
vendored
Normal file
@ -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"]
|
||||
}
|
||||
]
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -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
|
||||
|
@ -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()
|
||||
return time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + '【观看人数】' + '当前在线:' + str(self.instance.total) + ',历史总计:' + self.format_content()
|
Binary file not shown.
Binary file not shown.
@ -1,4 +1,3 @@
|
||||
import time
|
||||
import concurrent.futures
|
||||
import queue
|
||||
|
||||
|
@ -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")))
|
||||
|
Binary file not shown.
@ -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]
|
||||
|
||||
|
Reference in New Issue
Block a user