当用户说:
使用 OpenClaw 浏览器自动化 + CDP 协议:
内置 Bing Images 搜索,可根据关键词自动下载高清图:
无需 API Key,但需要:
页面URL: https://we.ctrip.com/publish/publishPictureText
关键选择器:
- 图片上传: input[type="file"] (隐藏元素,需用CDP)
- 标题输入: [role="textbox"] (第一个)
- 正文编辑器: [role="combobox"] (第一个)
- 地点选择: .ant-select-selection-search-input
- 日期选择: input[placeholder*="日期"]
- 发布按钮: button (innerText = "发 布")
- 存草稿: button (innerText = "存草稿")
- 水印开关: .ant-switch
detail?articleId=import json, asyncio, websockets
async def upload_images(ws_url, files):
async with websockets.connect(ws_url) as ws:
# 获取DOM文档
await ws.send(json.dumps({
"id": 1,
"method": "DOM.getDocument",
"params": {"depth": -1}
}))
doc = json.loads(await ws.recv())
# 查找file input
await ws.send(json.dumps({
"id": 2,
"method": "DOM.querySelector",
"params": {
"nodeId": doc["result"]["root"]["nodeId"],
"selector": "input[type='file']"
}
}))
q = json.loads(await ws.recv())
# 设置文件
await ws.send(json.dumps({
"id": 3,
"method": "DOM.setFileInputFiles",
"params": {
"nodeId": q["result"]["nodeId"],
"files": files # 绝对路径列表
}
}))
用户:帮我发一篇北京3天2晚的攻略到携程
AI:
共 1 个版本