Merge pull request #909 from Miracle778/fix-zhihu-specified-id-cdp

fix: 修复知乎 specified_id 和已有 Chrome CDP 连接问题
This commit is contained in:
程序员阿江-Relakkes
2026-06-16 20:40:47 +08:00
committed by GitHub
2 changed files with 5 additions and 4 deletions

View File

@@ -382,6 +382,8 @@ async def parse_cmd(argv: Optional[Sequence[str]] = None):
config.TIEBA_SPECIFIED_ID_LIST = [
_normalize_tieba_note_id(item) for item in specified_id_list
]
elif platform == PlatformEnum.ZHIHU:
config.ZHIHU_SPECIFIED_ID_LIST = specified_id_list
if creator_id_list:
if platform == PlatformEnum.XHS:

View File

@@ -316,10 +316,9 @@ class CDPBrowserManager:
"""
try:
if config.CDP_CONNECT_EXISTING:
# For existing browser (e.g. chrome://inspect/#remote-debugging),
# Chrome exposes a WebSocket at /devtools/browser and may show a confirmation
# dialog to the user. Use ws:// with a longer timeout to wait for user confirmation.
ws_url = f"ws://localhost:{self.debug_port}/devtools/browser"
# Existing Chrome exposes the browser websocket URL from /json/version.
# Newer Chrome versions return a UUID path instead of plain /devtools/browser.
ws_url = await self._get_browser_websocket_url(self.debug_port)
utils.logger.info(f"[CDPBrowserManager] Connecting to existing browser via CDP: {ws_url}")
utils.logger.info(
"[CDPBrowserManager] Please check your browser for a confirmation dialog and accept it"