This commit is contained in:
mshe 2026-06-08 17:29:39 +08:00
parent 9ee583afcb
commit 2fd7792b7b
2 changed files with 3 additions and 3 deletions

2
app.py
View File

@ -24,7 +24,7 @@ async def mail_qq_spider(account: str,display: int) -> str:
data={"display": display}
try:
os.environ['DISPLAY'] = f':{display}'
result = await asyncio.to_thread(start_mail_qq_spider, account, display)
result = await asyncio.to_thread(start_mail_qq_spider, account)
data["status"] = 200
data["result"] = result
return json.dumps(data, ensure_ascii=False)

View File

@ -90,7 +90,7 @@ def crawl_with_saved_state(auth_file):
with sync_playwright() as p:
# 加载之前保存的登录状态
logging.info(f"加载认证文件: {auth_file}")
browser = p.chromium.launch(headless=False) # 可以无头模式了
browser = p.chromium.launch(headless=False,env={"DISPLAY": display}) # 可以无头模式了
context = browser.new_context(storage_state=auth_file)
page = context.new_page()
page.goto('https://mail.qq.com')
@ -133,4 +133,4 @@ def start(account):
save_login_state(file_path, "收件箱")
if __name__ == '__main__':
start("123", display=0)
start("123")