Smooth Browser技能使用说明
Smooth 浏览器
Smooth CLI 是一个供 AI 智能体与网站交互、进行身份验证、抓取数据以及使用自然语言执行复杂基于网页任务的浏览器。
前提条件
假设 Smooth CLI 已安装。如果尚未安装,您可以通过运行以下命令安装:

pip install smooth-py
假设 API 密钥已配置。如果遇到身份验证错误,请使用以下命令配置:
smooth config --api-key <api-key>
要验证配置:
smooth config --show
获取 API 密钥,请访问https://app.smooth.sh
如果账户余额不足,请提示用户在以下网址升级套餐:https://app.smooth.sh
基本工作流程
1. 创建配置文件(可选)
配置文件有助于在不同会话之间持久化 Cookie、登录会话和浏览器状态。
smooth create-profile --profile-id "my-profile"
列出已有配置文件:
smooth list-profiles
2. 启动浏览器会话
smooth start-session --profile-id "my-profile" --url "https://example.com"
选项:
--profile-id- 使用特定配置文件(可选,如未提供则创建匿名会话)--url- 初始导航URL(可选)--files- 以逗号分隔的文件ID,用于在会话中提供访问(可选)--device mobile|desktop- 设备类型(默认:mobile)--profile-read-only- 加载配置文件但不保存更改--allowed-urls- 以逗号分隔的URL模式,用于限制仅能访问特定URL(例如:"https://example.com/,https://api.example.com/")--no-proxy- 禁用默认代理(参见下方说明)
重要提示:请保存输出中的会话ID——所有后续命令都需要用到它。
代理行为说明:默认情况下,CLI会自动为浏览器会话配置一个内置代理。如果网站阻止了该代理,或者您需要直接连接,请使用--no-proxy 参数禁用它.
3. 在会话中运行任务
使用自然语言执行任务:
smooth run -- <session-id> "Go to the LocalLLM subreddit and find the top 3 posts"
使用结构化输出(针对需要交互的任务):
smooth run -- <session-id> "Search for 'wireless headphones', filter by 4+ stars, sort by price, and extract the top 3 results" \
--url "https://shop.example.com" \
--response-model '{"type":"array","items":{"type":"object","properties":{"product":{"type":"string","description":"Thenameoftheproductbeingdescribed."},"sentiment":{"type":"string","enum":["positive","negative","neutral"],"description":"The overall sentiment about the product."}},"required":["product","sentiment"]}}'
使用元数据(代理将):
smooth run -- <session-id> "Fill out the form with user information" \
--metadata '{"email":"user@example.com","name":"John Doe"}'
选项:
--url- 在运行任务前导航到此 URL--metadata- 包含任务变量的 JSON 对象--response-model- 用于结构化输出的 JSON 模式--max-steps- 最大代理步骤数(默认值:32)--json- 以 JSON 格式输出结果
注意:重要的是,您应以适当的抽象级别给出任务。既不能太过于规定性——例如,单步操作——也不能太宽泛或模糊。
良好任务示例:
- "在 LinkedIn 上搜索在亚马逊担任 SDE 的人员,并返回 5 个个人资料网址"
- "在亚马逊上查找iPhone 17的价格"
不良任务示例:
- "点击搜索" -> 过于指令化!
- "加载google.com,输入'我附近的餐厅',点击搜索,等待页面加载,提取前5个结果并返回。" -> 过于指令化!你可以说"在谷歌上搜索'我附近的餐厅'并返回前5个结果"
- "寻找适合我们公司的软件工程师" -> 过于宽泛!你需要规划如何实现目标,并运行明确定义的任务来组合达成既定目标
重要提示:Smooth由智能代理驱动,请勿过度控制,应给予其明确定义的目标导向型任务而非操作步骤。
4. 关闭会话
完成后必须关闭会话。
smooth close-session -- <session-id>
注意事项:关闭后等待5秒,以确保如需用于其他会话时,cookie和状态能保存至配置文件。
常见使用场景
身份验证与持久会话
为特定网站创建配置文件:
# Create profile
smooth create-profile --profile-id "github-account"
# Start session
smooth start-session --profile-id "github-account" --url "https://github.com/login"
# Get live view to authenticate manually
smooth live-view -- <session-id>
# Give the URL to the user so it can open it in the browser and log in
# When the user confirms the login you can then close the session to save the profile data
smooth close-session -- <session-id>
# Save the profile-id somewhere to later reuse it
复用已认证的配置文件:
# Next time, just start a session with the same profile
smooth start-session --profile-id "github-account"
smooth run -- <session-id> "Create a new issue in my repo 'my-project'"
保持配置文件组织有序:保存到记忆中哪些配置文件验证了哪些服务,以便将来高效复用。
同一浏览器的顺序任务
在不关闭会话的情况下按顺序执行多个任务:
SESSION_ID=$(smooth start-session --profile-id "my-profile" --json | jq -r .session_id)
# Task 1: Login
smooth run $SESSION_ID "Log into the website with the given credentials"
# Task 2: First action
smooth run $SESSION_ID "Find the settings and change the notifications preferences to email only"
# Task 3: Second action
smooth run $SESSION_ID "Find the billing section and give me the url of the latest invoice"
smooth close-session $SESSION_ID
重要: 运行会保留浏览器状态(cookies、URL、页面内容),但不会保留浏览器代理的内存。如果需要将信息从一个任务传递到下一个任务,应在提示中明确传递。
示例 - 在任务间传递上下文:
# Task 1: Get information
RESULT=$(smooth run $SESSION_ID "Find the product name on this page" --json | jq -r .output)
# Task 2: Use information from Task 1
smooth run $SESSION_ID "Consider the product with name '$RESULT'. Now find 3 similar products offered by this online store."
注意:
- 运行命令是阻塞的。如果需要同时执行多个任务,必须使用子代理(任务工具)。
- 所有任务都将使用当前标签页,不能请求在新标签页中运行任务。如果需要保留当前标签页的状态,可以打开一个新会话。
- 每个会话一次只能运行一个任务。要同时运行任务,请使用每个会话一个子代理。
- 并发会话的最大数量取决于用户计划。
- 如有需要,请提醒用户他们可以升级计划以获得更多并发会话。
结构化输出网络爬取
方案一:使用run命令配合结构化输出:
smooth start-session --url "https://news.ycombinator.com"
smooth run -- <session-id> "Extract the top 10 posts" \
--response-model '{
"type": "object",
"properties": {
"posts": {
"type": "array",
"items": {
"type": "object",
"properties": {
"title": {"type": "string"},
"url": {"type": "string"},
"points": {"type": "number"}
}
}
}
}
}'
方案二:使用extract命令进行直接数据提取:
对于纯数据提取场景,extract命令更为高效,因为它无需经过代理步骤。
它就像智能抓取工具,能够从动态渲染的网站中提取结构化数据:
smooth start-session
smooth extract -- <session-id> \
--url "https://news.ycombinator.com" \
--schema '{
"type": "object",
"properties": {
"posts": {
"type": "array",
"items": {
"type": "object",
"properties": {
"title": {"type": "string"},
"url": {"type": "string"},
"points": {"type": "number"}
}
}
}
}
}' \
--prompt "Extract the top 10 posts"
使用场景对比:
- 当您已定位到目标页面或已知确切网址,只需提取结构化数据时,请使用
extract命令 - 当您需要代理进行页面导航、交互或执行复杂操作后再提取数据时,请使用
run命令
文件操作指南
在会话中使用文件的上传流程:
文件必须在启动会话前完成上传,随后通过文件ID传递至会话中:
# Step 1: Upload files
FILE_ID=$(smooth upload-file /path/to/document.pdf --purpose "Contract to analyze" --json | jq -r .file_id)
# Step 2: Start session with the file
smooth start-session --files "$FILE_ID" --url "https://example.com"
# Step 3: The agent can now access the file in tasks
smooth run -- <session-id> "Analyze the contract document and extract key terms"
上传多个文件:
# Upload files
FILE_ID_1=$(smooth upload-file /path/to/invoice.pdf --json | jq -r .file_id)
FILE_ID_2=$(smooth upload-file /path/to/screenshot.png --json | jq -r .file_id)
# Start session with multiple files
smooth start-session --files "$FILE_ID_1,$FILE_ID_2"
从会话下载文件:
smooth run -- <session-id> "Download the monthly report PDF" --url
smooth close-session -- <session-id>
# After session closes, get download URL
smooth downloads -- <session-id>
# Visit the URL to download files
实时查看与手动干预
当自动化需要人工输入时(验证码、双重认证、复杂身份验证):
smooth start-session --profile-id "my-profile"
smooth run -- <session-id> "Go to secure-site.com and log in"
# If task encounters CAPTCHA or requires manual action:
smooth live-view -- <session-id>
# Open the URL and complete the manual steps
# Continue automation after manual intervention:
smooth run -- <session-id> "Now navigate to the dashboard and export data"
直接浏览器操作
从当前页面提取数据:
smooth start-session --url "https://example.com/products"
smooth extract -- <session-id> \
--schema '{"type":"object","properties":{"products":{"type":"array"}}}' \
--prompt "Extract all product names and prices"
导航至URL后提取:
smooth extract -- <session-id> \
--url "https://example.com/products" \
--schema '{"type":"object","properties":{"products":{"type":"array"}}}'
在浏览器中执行JavaScript:
# Simple JavaScript
smooth evaluate-js -- <session-id> "document.title"
# With arguments
smooth evaluate-js -- <session-id> "(args) => {return args.x + args.y;}" --args '{"x": 5, "y": 10}'
# Complex DOM manipulation
smooth evaluate-js -- <session-id> \
"document.querySelectorAll('a').length"
配置文件管理
列出所有配置文件:
smooth list-profiles
删除配置文件:
smooth delete-profile <profile-id>
何时使用配置文件:
- ✅ 需要身份验证的网站
- ✅ 在多次任务运行间保持会话状态
- ✅ 避免重复登录
- ✅ 保留Cookie和本地存储
何时跳过配置文件:
- 无需身份验证的公共网站
- 一次性抓取任务
- 测试场景
文件管理
上传文件:
smooth upload-file /path/to/file.pdf --name "document.pdf" --purpose "Contract for review"
删除文件:
smooth delete-file <file-id>
最佳实践
- 始终保存会话ID- 后续命令将需要用到它们
- 对于已认证的会话使用配置文件- 记录每个配置文件对应哪个网站
- 关闭会话后等待5秒- 确保状态被正确保存
- 使用描述性的配置文件ID- 例如:"linkedin-personal"、"twitter-company"
- 完成后关闭会话- 优雅关闭(默认)能确保正确的清理工作
- 数据提取使用结构化输出- 提供干净、类型化的结果
- 在同一会话中运行顺序任务- 当步骤依赖于先前工作时,保持会话连续。
- 对于独立任务,为每个子代理分配一个会话- 并行运行任务以加快工作速度。
- 协调资源- 使用子代理时,你必须为每个子代理创建并分配一个部分,而不是让它们自行创建。
- 不要向URL添加查询参数,例如避免
?filter=xyz- 从基础URL开始,让代理通过导航UI来应用筛选条件。 - Smooth由智能代理驱动- 给它分配任务,而不是单个步骤。
故障排除
"会话未找到"- 会话可能已超时或关闭。请启动一个新的会话。
"配置文件未找到"- 检查smooth list-profiles以查看可用的配置文件。
验证码或身份验证问题- 使用smooth live-view -- <会话ID>让用户手动干预。
任务超时- 增加--max-steps或将任务分解为更小的步骤。
命令参考
配置文件命令
smooth create-profile [--profile-id ID]- 创建新的配置文件smooth list-profiles- 列出所有配置文件smooth delete-profile <profile-id>- 删除配置文件
文件命令
smooth upload-file <path> [--name NAME] [--purpose PURPOSE]- 上传文件smooth delete-file <file-id>- 删除已上传的文件
会话命令
smooth start-session [OPTIONS]- 启动浏览器会话smooth close-session -- <session-id> [--force]- 关闭会话smooth run -- <session-id> "<task>" [OPTIONS]- 运行任务smooth extract -- <session-id> --schema SCHEMA [OPTIONS]- 提取结构化数据smooth evaluate-js -- <会话ID> "代码" [--args JSON]- 执行JavaScriptsmooth live-view -- <会话ID>- 获取交互式实时URLsmooth recording-url -- <会话ID>- 获取录制URLsmooth downloads -- <会话ID>- 获取下载URL
所有命令均支持--json标志以输出JSON格式。


微信扫一扫,打赏作者吧~