feat: 支持playwright通过cdp协议连接本地chrome浏览器

docs: 增加uv来管理python依赖的文档
This commit is contained in:
程序员阿江(Relakkes)
2025-06-25 23:22:39 +08:00
parent fbc9788d54
commit e83b2422d9
10 changed files with 991 additions and 52 deletions

View File

@@ -12,7 +12,7 @@
from abc import ABC, abstractmethod
from typing import Dict, Optional
from playwright.async_api import BrowserContext, BrowserType
from playwright.async_api import BrowserContext, BrowserType, Playwright
class AbstractCrawler(ABC):
@@ -43,6 +43,19 @@ class AbstractCrawler(ABC):
"""
pass
async def launch_browser_with_cdp(self, playwright: Playwright, playwright_proxy: Optional[Dict],
user_agent: Optional[str], headless: bool = True) -> BrowserContext:
"""
使用CDP模式启动浏览器可选实现
:param playwright: playwright实例
:param playwright_proxy: playwright代理配置
:param user_agent: 用户代理
:param headless: 无头模式
:return: 浏览器上下文
"""
# 默认实现:回退到标准模式
return await self.launch_browser(playwright.chromium, playwright_proxy, user_agent, headless)
class AbstractLogin(ABC):
@abstractmethod