跳转到主要内容
NPM 包: olostep-cli Olostep API 的 CLI:mapanswerscrapescrape-getcrawlbatch-scrapebatch-update。响应为用于脚本、CI 和代理的 JSON(美化打印)。 安装此包会为你的操作系统下载一个独立的二进制文件。你不需要 Python 来运行 olostep
在安装时,postinstall 步骤会从包的 GitHub releases 下载匹配的二进制文件。如果失败,请确认该包版本和你的平台是否存在发布版本,然后重新安装。

安装

要求: Node.js 16+(仅用于 npm / npx; CLI 本身是一个本地二进制文件)。
npm install -g olostep-cli
无需全局安装即可运行:
npx -y olostep-cli@latest --help
平台: macOS(Apple Silicon 和 Intel)、Linux x64、Windows x64。

API 密钥

在你的环境中设置 OLOSTEP_API_KEY,或在运行 olostep 的目录中设置 .env 文件。 创建密钥:Olostep API 密钥
export OLOSTEP_API_KEY=your_key_here
olostep --help

输出

标志行为
--out <path>将 JSON 写入文件(如有需要,创建父目录)。
--out -仅将 JSON 写入 stdout(UTF-8,缩进)。适用于管道和子进程捕获。
进度和日志行发送到 stderr,因此 stdout 保持可解析。
olostep map "https://example.com" --top-n 20 --out - | jq '.urls[:10]'
olostep scrape "https://example.com" --out - | jq .result.markdown_content
如果省略 --out,文件将放在 output/ 下(参见 默认 --out 路径)。

命令

使用 olostep <command> --help 查看每个选项。大多数命令接受 --timeout(HTTP,秒)。

map: 发现 URL

选项描述
--out文件路径或 -
--top-n最大 URL 数
--search-query引导发现
--include-subdomain / --no-include-subdomain子域名
--include-url / --exclude-url可重复的模式
--cursor分页
使用 --top-n,而不是 --limit(已移除)。
olostep map "https://example.com" --top-n 100 --search-query "blog"

answer: 研究答案

轮询直到答案准备好。
选项描述
--out文件或 -
--json-format可选的结构化输出提示(JSON 对象字符串)
--poll-interval / --poll-timeout轮询(秒)
使用 --json-format,而不是 --model(已移除)。
olostep answer "What does this company build?" --out answer.json
olostep answer "Extract facts" --json-format '{"company":"","year":""}' --out -

scrape: 单个 URL

格式: htmlmarkdowntextjsonraw_pdfscreenshot(逗号分隔;默认 markdown)。
选项描述
--formats逗号分隔
--country国家代码
--wait-before-scraping抓取前等待的毫秒数
--payload-json高级选项作为 JSON 对象字符串
--payload-file同上,从文件中读取(不能与 --payload-json 一起使用)
olostep scrape "https://example.com" --formats markdown,html
olostep scrape "https://example.com" --payload-file scrape-options.json --out -

scrape-get: 通过抓取 ID

olostep scrape-get "scrape_abc123" --out -

crawl: 网站爬取

检索格式: markdownhtmljson 重要标志:--max-pages--max-depth--include-subdomain--include-external--include-url--exclude-url--search-query--top-n--webhook--crawl-timeout--follow-robots-txt / --ignore-robots-txt--formats--pages-limit--pages-search-query--poll-seconds--poll-timeout--dry-run(打印负载,无请求)。
olostep crawl "https://docs.example.com" --max-pages 50 --formats markdown,html
olostep crawl "https://example.com" --max-pages 10 --dry-run

batch-scrape: CSV

CSV 列:custom_idid,以及 url
选项描述
--formatsmarkdownhtmljson
--country可选
--parser-id结构化提取解析器
--poll-seconds--log-every--items-limit轮询 / 分页
--dry-run仅打印负载
olostep batch-scrape urls.csv --formats markdown,html

batch-update: 批量元数据

需要 以下之一 --metadata-json--metadata-file(JSON 对象)。
olostep batch-update "batch_abc123" --metadata-json '{"team":"growth"}'

默认 --out 路径

当省略 --out 时:
命令默认
mapoutput/map.json
answeroutput/answer.json
scrapeoutput/scrape.json
scrape-getoutput/scrape_get.json
crawloutput/crawl_results.json
batch-scrapeoutput/batch_results.json
batch-updateoutput/batch_update.json

全局标志

标志描述
-V, --version版本
-h, --help帮助

相关文档

仓库: github.com/olostep-api/CLI

安全

将 API 密钥保留在源代码控制之外;如果泄露,请旋转密钥。