mirror of
https://github.com/NanmiCoder/MediaCrawler.git
synced 2026-04-20 18:57:44 +08:00
feat: 支持playwright通过cdp协议连接本地chrome浏览器
docs: 增加uv来管理python依赖的文档
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user