From eefcf7a0a9ad36636fba3c3cbfb43cc9e52f6b0c Mon Sep 17 00:00:00 2001 From: protokey Date: Wed, 23 Sep 2026 16:49:05 +0400 Subject: [PATCH] =?UTF-8?q?chore:=20=D0=B0=D0=BF=D0=B8=20=D0=B2=D1=81?= =?UTF-8?q?=D0=B5=D0=B3=D0=B4=D0=B0=20=D0=B2=D0=BE=D0=B7=D0=B2=D1=80=D0=B0?= =?UTF-8?q?=D1=89=D0=B0=D0=B5=D1=82=20=D0=BE=D1=82=D0=B2=D0=B5=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.py | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/src/main.py b/src/main.py index 1df6b16..dce83ab 100644 --- a/src/main.py +++ b/src/main.py @@ -1,5 +1,6 @@ import json import logging +import traceback import uuid from pathlib import Path from typing import Annotated @@ -157,21 +158,28 @@ async def solve( async with AsyncStealthySession(**kwargs) as engine: result = await engine.fetch(payload.url, page_action=make_page_action(payload)) + except Exception as e: + traceback.print_exc() + result_payload = { + "error": str(e), + "status": False + } + else: + status = not "error" in result["actions"][-1] + error = ["Something error", None][status] + + result_payload = { + "status": ["err", "ok"][status], + "user_agent": result["user_agent"], + "cookies": result["cookies"], + "actions": result["actions"], + } + if payload.html: + result_payload["html"] = result["html"] + if error: + result_payload["error"] = error finally: BROWSER_SLOTS += 1 - status = not "error" in result["actions"][-1] - error = ["Something error", None][status] - - result_payload = { - "status": ["err", "ok"][status], - "user_agent": result["user_agent"], - "cookies": result["cookies"], - "actions": result["actions"], - } - if payload.html: - result_payload["html"] = result["html"] - if error: - result_payload["error"] = error logger.info("Outgoing payload:\n%s", json.dumps(result_payload, indent=2, sort_keys=True, ensure_ascii=True)) return result_payload