From 2fd7792b7b486ace1c814422bb530d5776bd8037 Mon Sep 17 00:00:00 2001 From: mshe <666666666@666666666.666666666> Date: Mon, 8 Jun 2026 17:29:39 +0800 Subject: [PATCH] fix bugs --- app.py | 2 +- spider/mail_qq.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index 0afcfb3..e973e17 100755 --- a/app.py +++ b/app.py @@ -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) diff --git a/spider/mail_qq.py b/spider/mail_qq.py index 426aea5..d5888c3 100644 --- a/spider/mail_qq.py +++ b/spider/mail_qq.py @@ -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) \ No newline at end of file + start("123") \ No newline at end of file