python-drission-page-spider/worker.py
shikong 7a19ca02bf
refactor: 重构日志系统并优化线程池配置
重构日志系统,使用loguru替代print语句,提升日志管理能力。优化线程池配置,根据CPU核心数动态设置线程池大小。将任务执行逻辑移至worker.py,提高代码可维护性。
2025-03-21 00:55:10 +08:00

27 lines
768 B
Python

from listener.console import *
from listener.network import *
def run_task(browser, executor, log):
tab = browser.latest_tab
executor.submit(console_listener, tab)
executor.submit(network_listener, tab, targets=[
"/api"
])
tab.get(url='http://127.0.0.1:24613')
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()
items = tab.eles("t:body")
for item in items:
print(item)