python-drission-page-spider/worker.py

34 lines
1.0 KiB
Python
Raw Permalink Normal View History

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.set.window.size(int(1024 * 1.25), int(768 * 1.25))
tab.set.user_agent(
ua="Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Mobile Safari/537.36",
platform='android'
)
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.wait(2)
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:
log.info(item)