mirror of
https://github.com/j93es/browser-use-oauth.git
synced 2026-06-04 07:01:51 +09:00
[Enhancement] setup_storage_state 및 GetProfile 함수를 비동기 처리로 변경
This commit is contained in:
parent
adec1f5e49
commit
7ae5834d82
3 changed files with 5 additions and 6 deletions
|
|
@ -2,11 +2,10 @@ from lib.utils.browser_use.func import *
|
||||||
|
|
||||||
# Initialize configuration
|
# Initialize configuration
|
||||||
proxy_url = setup_proxy()
|
proxy_url = setup_proxy()
|
||||||
storage_state_path = setup_storage_state()
|
|
||||||
|
|
||||||
# Create browser profile
|
# Create browser profile
|
||||||
def GetProfile():
|
async def GetProfile():
|
||||||
setup_storage_state()
|
storage_state_path = await setup_storage_state()
|
||||||
profile = BrowserProfile(
|
profile = BrowserProfile(
|
||||||
# Security settings
|
# Security settings
|
||||||
disable_security=True,
|
disable_security=True,
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ def setup_proxy():
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def setup_storage_state():
|
async def setup_storage_state():
|
||||||
"""Setup browser storage state for session persistence."""
|
"""Setup browser storage state for session persistence."""
|
||||||
# Get the script directory to ensure correct path resolution
|
# Get the script directory to ensure correct path resolution
|
||||||
script_dir = Path(__file__).parent.parent.parent.parent
|
script_dir = Path(__file__).parent.parent.parent.parent
|
||||||
|
|
|
||||||
4
main.py
4
main.py
|
|
@ -84,7 +84,7 @@ signal.signal(signal.SIGINT, signal_handler)
|
||||||
|
|
||||||
# ── URL별로 Browser를 새로 띄우는 함수 ──
|
# ── URL별로 Browser를 새로 띄우는 함수 ──
|
||||||
async def scan_one_url(url: str, skip_html_check: bool = False):
|
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}"
|
target_url = url if url.startswith("http") else f"https://{url}"
|
||||||
print(f"🚀 Starting scan for: {target_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 전달
|
# BrowserSession에 profile 전달
|
||||||
session = BrowserSession(
|
session = BrowserSession(
|
||||||
playwright=(await async_patchright().start()),
|
playwright=(await async_patchright().start()),
|
||||||
browser_profile=browser_use.GetProfile(),
|
browser_profile=await browser_use.GetProfile(),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Agent 생성 및 실행 (단일 try-except with 백오프)
|
# Agent 생성 및 실행 (단일 try-except with 백오프)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue