From be1b995304e5d226fb866f03384cb8cfb2b38fff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=81=BC=E7=9C=BC=E8=80=85?= <821986597@qq.com> Date: Tue, 8 Oct 2024 11:45:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E6=89=93=E5=8D=B0?= =?UTF-8?q?=E7=9F=AD=E4=BF=A1=E9=AA=8C=E8=AF=81=E7=A0=81=E8=AF=86=E5=88=AB?= =?UTF-8?q?=E6=96=87=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/main.py b/main.py index 34be0d6..4c3da49 100644 --- a/main.py +++ b/main.py @@ -290,10 +290,6 @@ async def auto_shape(page, retry_times: int = 5): async def sms_recognition(page, user): - logger.info("开始短信验证码识别") - if await page.locator('text="手机短信验证"').count() == 0: - return - try: from config import sms_func except ImportError: @@ -305,7 +301,7 @@ async def sms_recognition(page, user): raise Exception(f"sms_func只支持{supported_sms_func}") if sms_func == "no": - raise Exception("需要填写验证码") + raise Exception("sms_func为no关闭, 跳过短信验证码识别环节") logger.info('点击【获取验证码】中') await page.click('button.getMsg-btn') @@ -404,7 +400,9 @@ async def get_jd_pt_key(playwright: Playwright, user) -> Union[str, None]: # 进行短信验证识别 await asyncio.sleep(1) - await sms_recognition(page, user) + if await page.locator('text="手机短信验证"').count() != 0: + logger.info("开始短信验证码识别环节") + await sms_recognition(page, user) # 等待验证码通过 logger.info("等待获取cookie...")