From adec1f5e49837f90b7f2ef8a7aa76a44994c4eee Mon Sep 17 00:00:00 2001 From: imnyang Date: Sun, 15 Jun 2025 22:36:20 +0900 Subject: [PATCH] =?UTF-8?q?[Enhancement]=20GetProfile=20=ED=95=A8=EC=88=98?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80=20=EB=B0=8F=20=EB=B8=8C=EB=9D=BC=EC=9A=B0?= =?UTF-8?q?=EC=A0=80=20=ED=94=84=EB=A1=9C=ED=95=84=20=EC=83=9D=EC=84=B1=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=ED=86=B5=ED=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/utils/browser_use/__init__.py | 46 +++++++++++++++++-------------- main.py | 2 +- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/lib/utils/browser_use/__init__.py b/lib/utils/browser_use/__init__.py index cde80d6..11168e1 100644 --- a/lib/utils/browser_use/__init__.py +++ b/lib/utils/browser_use/__init__.py @@ -5,24 +5,28 @@ proxy_url = setup_proxy() storage_state_path = setup_storage_state() # Create browser profile -profile = BrowserProfile( - # Security settings - disable_security=True, - stealth=True, - - # Display settings - headless=False, - device_scale_factor=1, - window_size={"width": 1600, "height": 900}, - viewport={"width": 1600, "height": 900}, - - # Data persistence - user_data_dir=None, - storage_state=storage_state_path, - - # Network settings - proxy={"server": proxy_url} if proxy_url else None, - - # Additional arguments - args=get_browser_args(), -) \ No newline at end of file +def GetProfile(): + setup_storage_state() + profile = BrowserProfile( + # Security settings + disable_security=True, + stealth=True, + + # Display settings + headless=False, + device_scale_factor=1, + window_size={"width": 1600, "height": 900}, + viewport={"width": 1600, "height": 900}, + + # Data persistence + user_data_dir=None, + storage_state=storage_state_path, + + # Network settings + proxy={"server": proxy_url} if proxy_url else None, + + # Additional arguments + args=get_browser_args(), + ) + + return profile \ No newline at end of file diff --git a/main.py b/main.py index 87a2554..8b150a1 100644 --- a/main.py +++ b/main.py @@ -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.profile, + browser_profile=browser_use.GetProfile(), ) # Agent 생성 및 실행 (단일 try-except with 백오프)