fix: 쿠키 삭제 및 페이지 새로 고침 관련 문서 수정, 의존성 버전 하향 조정

This commit is contained in:
암냥 2025-06-21 15:49:48 +09:00
commit f157039351
4 changed files with 4 additions and 41 deletions

View file

@ -79,7 +79,7 @@ extend_planner_system_message = f"""
- **로그인 완료 authorize 버튼이 있으면 클릭**
- GitHub같은 경우 Authorize 버튼이 뜨는데 오래걸릴 있음, 기다려야 수도 있음
- 만약 버튼을 눌러도 반응이 없을 경우 새로고침을 한번 해주세요.
4. 로그인 성공 clear all cookies, then reload the page 모두 쿠키를 삭제하고 다음 SSO 버튼을 클릭합니다.
4. 로그인 성공 모두 쿠키를 삭제하고 다음 SSO 버튼을 클릭합니다.
5. 다음 SSO 버튼으로 반복 진행
🛑 절대 아래와 같이 해석하지 :

39
main.py
View file

@ -15,6 +15,7 @@ from browser_use import (
ActionResult,
)
from patchright.async_api import async_playwright as async_patchright, Page
from pydantic import BaseModel
from lib.utils import env_cheker
from lib.utils.backend_client import notify_backend
@ -111,44 +112,6 @@ async def scan_one_url(url: str, skip_html_check: bool = False):
# Agent 생성 및 실행 (단일 try-except with 백오프)
initial_actions = [{"open_tab": {"url": target_url}}]
controller = Controller(output_model=model.BaseModel, exclude_actions=['search_google'])
@controller.action('Clear all cookies and reload page')
async def clear_cookies(browser_session: BrowserSession) -> ActionResult:
print("🔧 Executing clear_cookies action...")
# Get the current page
page = await browser_session.get_current_page()
if not page:
print("❌ 현재 페이지를 찾을 수 없습니다. 쿠키를 지울 수 없습니다.")
return ActionResult(
extracted_content="현재 페이지를 찾을 수 없습니다.",
include_in_memory=True
)
if not isinstance(page, Page):
print("❌ 현재 페이지가 올바른 타입이 아닙니다. 쿠키를 지울 수 없습니다.")
return ActionResult(
extracted_content="현재 페이지가 올바른 타입이 아닙니다.",
include_in_memory=True
)
print(f"🔍 현재 페이지 URL: {page.url}")
try:
# Clear all cookies for the current context
await page.context.clear_cookies()
await page.context.clear_permissions()
await page.reload()
print("🗑️ All cookies have been cleared and page reloaded.")
return ActionResult(
extracted_content="Successfully cleared all cookies and reloaded the page",
include_in_memory=True
)
except Exception as e:
print(f"❌ Error clearing cookies: {e}")
return ActionResult(
extracted_content=f"Failed to clear cookies: {str(e)}",
include_in_memory=True
)
print("🤖 LLM 모델 초기화 및 스캔 시작...")
print("Available actions:", list(controller.registry.registry.actions.keys()))

View file

@ -5,7 +5,7 @@ description = "Add your description here"
readme = "README.md"
requires-python = ">=3.13"
dependencies = [
"browser-use[memory]>=0.3.1",
"browser-use[memory]>=0.2.7",
"lmnr[all]>=0.6.10",
"patchright>=1.52.5",
]

2
uv.lock generated
View file

@ -150,7 +150,7 @@ dependencies = [
[package.metadata]
requires-dist = [
{ name = "browser-use", extras = ["memory"], specifier = ">=0.3.1" },
{ name = "browser-use", extras = ["memory"], specifier = ">=0.2.7" },
{ name = "lmnr", extras = ["all"], specifier = ">=0.6.10" },
{ name = "patchright", specifier = ">=1.52.5" },
]