惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The Last Watchdog
The Last Watchdog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
S
Secure Thoughts
MongoDB | Blog
MongoDB | Blog
博客园 - Franky
T
Tor Project blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Google DeepMind News
Google DeepMind News
L
LINUX DO - 最新话题
博客园_首页
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Vercel News
Vercel News
Last Week in AI
Last Week in AI
月光博客
月光博客
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Proofpoint News Feed
博客园 - 叶小钗
NISL@THU
NISL@THU
C
Check Point Blog
K
Kaspersky official blog
N
News and Events Feed by Topic
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
A
Arctic Wolf
T
Threatpost
GbyAI
GbyAI
L
LINUX DO - 热门话题
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Privacy & Cybersecurity Law Blog
N
News and Events Feed by Topic
Scott Helme
Scott Helme
P
Privacy International News Feed
The Register - Security
The Register - Security
G
GRAHAM CLULEY
Recorded Future
Recorded Future
Apple Machine Learning Research
Apple Machine Learning Research
C
Cybersecurity and Infrastructure Security Agency CISA
B
Blog
Project Zero
Project Zero
Cyberwarzone
Cyberwarzone
Webroot Blog
Webroot Blog
Microsoft Security Blog
Microsoft Security Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
D
DataBreaches.Net
J
Java Code Geeks
AWS News Blog
AWS News Blog
Help Net Security
Help Net Security
Engineering at Meta
Engineering at Meta
M
MIT News - Artificial intelligence
T
Threat Research - Cisco Blogs
Google DeepMind News
Google DeepMind News

博客园 - HotSky

WPF 让ScrollViewer支持按住鼠标中键拖拽滚动内容 WPF 让ScrollViewer支持鼠标中键滚动缩放内容 Nodejs使用 nodejs中写sql需要用in时的写法 C#城市最短路径 C#Animation Sqlite PDF附录A: 内容流操作码 WPF FPS类 生命模拟 C# Sql帮助类,可扩展 WPF WriteableBitmap通过GDI+绘制帮助类 Alpha混合 Bmp读写二值图 WPF支持任意快捷键+鼠标组合的绑定类 WPF阻止窗体被系统缩放,使用显示器DPI WPF DataGrid自动增长序号列 C#访问或修改私有类、函数、变量、属性 WPF一个简单的属性编辑控件
Chrome启用CDP(chrome-devtools-protocol)进行远程操控
HotSky · 2026-04-15 · via 博客园 - HotSky

首先指定一个端口号让Chrome启动调试端口,(比如9222).

然后控制端请求链接获取webSocketUrl:

get->http://localhost:9222/json/version
response->
{
   "Browser": "Chrome/146.0.7680.165",
   "Protocol-Version": "1.3",
   "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36",
   "V8-Version": "14.6.202.26",
   "WebKit-Version": "537.36 (@4b989da09e15a7dc0de0785cb5ff232aadae3f0f)",
   "webSocketDebuggerUrl": "ws://localhost:9222/devtools/browser/6add6d6c-1e34-42d0-ad9e-ea2ba6c89d46"
}

Chome启动的调试服务只能本地访问,所以远程操控需要在Chrome本机建立一个中间件负责转发服务端(比如AI)与Chrome的消息.


CDP交互
根据webSocketDebuggerUrl建立websocket连接
连接成功后:
第一步: 找到目标页面

request->
{
    "id": 3,
    "method": "Target.getTargets"
}
response->
{
    "id": 3,
    "result": {
        "targetInfos": [
            {
                "targetId": "554623D25BC2C68CC7D297D75B961907",
                "type": "page",
                "title": "\u6b61\u8fce\u9032\u5165\u5370\u5237\u7ba1\u7406\u7cfb\u7d71",
                "url": "https://www.cnblogs.com",
                "attached": false,
                "canAccessOpener": false,
                "browserContextId": "1879DCC4254178FA61BF5A50BD5AE5F8"
            }
        ]
    }
}

第二步:选择目标页面

request->
{
    "id": 3,
    "method": "Target.attachToTarget",
    "params": {
      "targetId": "554623D25BC2C68CC7D297D75B961907",
      "flatten": true
    }
}
response->
{
    "id": 3,
    "result": {
        "sessionId": "534C416CD626D79CBC8188AB019CCB87"
    }
}


第三步:使用sessionId发送操作

request->
{
    "sessionId": "534C416CD626D79CBC8188AB019CCB87",
    "id": 3,
    "method": "Runtime.evaluate",
    "params": {
      "expression": "document.title"
    }
}
response->
{
    "id": 3,
    "result": {
        "result": {
            "type": "string",
            "value": "\u6b61\u8fce\u9032\u5165\u5370\u5237\u7ba1\u7406\u7cfb\u7d71"
        }
    },
    "sessionId": "064E8FC93CE1DADF3DB527D314E54215"
}

参考网址:
CDP (Chrome DevTools Protocol) 完整指南:从原理到 OpenClaw 实践

协议监控:查看和发送 CDP 请求  |  Chrome DevTools  |  Chrome for Developers

使用新的命令编辑器高效编写 Chrome Devtools 协议 (CDP) 命令  |  Blog  |  Chrome for Developers

https://github.com/aslushnikov/getting-started-with-cdp