From 7ae5834d82ea50ebf7b38f45c5edd0843a7367d5 Mon Sep 17 00:00:00 2001 From: imnyang Date: Sun, 15 Jun 2025 22:37:35 +0900 Subject: [PATCH] =?UTF-8?q?[Enhancement]=20setup=5Fstorage=5Fstate=20?= =?UTF-8?q?=EB=B0=8F=20GetProfile=20=ED=95=A8=EC=88=98=EB=A5=BC=20?= =?UTF-8?q?=EB=B9=84=EB=8F=99=EA=B8=B0=20=EC=B2=98=EB=A6=AC=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/utils/browser_use/__init__.py | 5 ++--- lib/utils/browser_use/func.py | 2 +- main.py | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/utils/browser_use/__init__.py b/lib/utils/browser_use/__init__.py index 11168e1..c38ca03 100644 --- a/lib/utils/browser_use/__init__.py +++ b/lib/utils/browser_use/__init__.py @@ -2,11 +2,10 @@ from lib.utils.browser_use.func import * # Initialize configuration proxy_url = setup_proxy() -storage_state_path = setup_storage_state() # Create browser profile -def GetProfile(): - setup_storage_state() +async def GetProfile(): + storage_state_path = await setup_storage_state() profile = BrowserProfile( # Security settings disable_security=True, diff --git a/lib/utils/browser_use/func.py b/lib/utils/browser_use/func.py index f44b2dd..31eee31 100644 --- a/lib/utils/browser_use/func.py +++ b/lib/utils/browser_use/func.py @@ -20,7 +20,7 @@ def setup_proxy(): return None -def setup_storage_state(): +async def setup_storage_state(): """Setup browser storage state for session persistence.""" # Get the script directory to ensure correct path resolution script_dir = Path(__file__).parent.parent.parent.parent diff --git a/main.py b/main.py index 8b150a1..ccc70bf 100644 --- a/main.py +++ b/main.py @@ -84,7 +84,7 @@ signal.signal(signal.SIGINT, signal_handler) # ── URL별로 Browser를 새로 띄우는 함수 ── async def scan_one_url(url: str, skip_html_check: bool = False): - setup_storage_state() + await setup_storage_state() target_url = url if url.startswith("http") else f"https://{url}" print(f"🚀 Starting scan for: {target_url}") @@ -103,7 +103,7 @@ async def scan_one_url(url: str, skip_html_check: bool = False): # BrowserSession에 profile 전달 session = BrowserSession( playwright=(await async_patchright().start()), - browser_profile=browser_use.GetProfile(), + browser_profile=await browser_use.GetProfile(), ) # Agent 생성 및 실행 (단일 try-except with 백오프)