2025-03-19 20:26:49 +08:00
|
|
|
from DrissionPage import Chromium, ChromiumOptions, SessionPage
|
|
|
|
from concurrent.futures import ThreadPoolExecutor
|
|
|
|
import atexit
|
2025-03-20 00:52:31 +08:00
|
|
|
|
|
|
|
import listener.console
|
|
|
|
import listener.network
|
|
|
|
|
2025-03-19 20:26:49 +08:00
|
|
|
|
|
|
|
options = ChromiumOptions()
|
|
|
|
# 无头模式
|
|
|
|
# options.headless()
|
|
|
|
|
2025-03-20 00:52:31 +08:00
|
|
|
import os
|
|
|
|
os.environ.setdefault('PYTHONIOENCODING', 'utf-8')
|
|
|
|
print(os.environ)
|
|
|
|
|
2025-03-19 20:26:49 +08:00
|
|
|
browser = Chromium(options)
|
|
|
|
tab = browser.latest_tab
|
|
|
|
|
|
|
|
executor = ThreadPoolExecutor(max_workers=2)
|
2025-03-20 00:52:31 +08:00
|
|
|
executor.submit(listener.console.console_listener, tab)
|
|
|
|
executor.submit(listener.network.network_listener, tab)
|
|
|
|
|
2025-03-19 20:26:49 +08:00
|
|
|
|
2025-03-19 20:53:17 +08:00
|
|
|
tab.get(url='http://127.0.0.1:24613')
|
2025-03-19 20:26:49 +08:00
|
|
|
|
2025-03-20 03:32:11 +08:00
|
|
|
tab.wait.url_change(text="/auth/login", timeout=3, raise_err=False)
|
|
|
|
|
|
|
|
if tab.url.endswith("/auth/login"):
|
|
|
|
tab.wait.doc_loaded()
|
|
|
|
tab.actions.move_to("@@t()=input@@type=text").click().type("shikong")
|
|
|
|
tab.actions.move_to("@@t()=input@@type=password").click().type("123+AbC")
|
|
|
|
tab.actions.move_to("@@t()=button@@text():登录").click()
|
|
|
|
|
|
|
|
tab.change_mode()
|
2025-03-19 20:26:49 +08:00
|
|
|
|
|
|
|
items = tab.eles("t:body")
|
|
|
|
for item in items:
|
|
|
|
print(item)
|
|
|
|
|
|
|
|
def exit():
|
|
|
|
print('exit')
|
|
|
|
browser.quit()
|
|
|
|
executor.shutdown()
|
|
|
|
|
|
|
|
atexit.register(exit)
|