Screenshots API
将任意 URL 渲染为 PNG 或 JPEG。仅视口或整页、桌面或移动端,并具备主 API 的全部 JS 渲染控制能力。非常适合预览、监控和快照场景。
相同的 JS 渲染管线,截图参数已添加到标准 endpoint 上。独立的 Screenshots API 自 2024 年 11 月 1 日起已停止接受新用户注册,现有集成继续可用,未安排关停计划。
Endpoint
# Requires a JavaScript token (rendering happens in headless Chrome).
# Returns the image bytes directly. Content-Type: image/png (default).快速开始
# Save the screenshot to disk
curl 'https://api.crawlbase.com/screenshots?token=YOUR_JS_TOKEN' \
--data-urlencode 'url=https://github.com/anthropic' \
-o screenshot.png -Gfrom crawlbase import ScreenshotsAPI
api = ScreenshotsAPI({'token': 'YOUR_JS_TOKEN'})
res = api.get('https://github.com/anthropic')
with open('screenshot.png', 'wb') as f:
f.write(res['body'])const { ScreenshotsAPI } = require('crawlbase');
const fs = require('node:fs/promises');
const api = new ScreenshotsAPI({ token: 'YOUR_JS_TOKEN' });
const res = await api.get('https://github.com/anthropic');
await fs.writeFile('screenshot.png', res.body);参数
必填参数
http 或 https 开头,并且经过完整的 URL 编码。截图专用参数
mode=fullpage 时该参数被忽略。width=375、height=812,并使用手机 User-Agent。渲染控制
继承自 Crawling API 参数集。客户端在截图中最常使用的渲染控制参数:
#some-button、.some-other-button)。请对值进行 URL 编码。scroll_interval(10–60 秒)配合以延长滚动时间。对于 mode=fullpage 截图中折叠以下的懒加载内容很有用。常见模式
整页移动端截图
curl 'https://api.crawlbase.com/screenshots?token=YOUR_JS_TOKEN' \
--data-urlencode 'url=https://news.ycombinator.com' \
--data-urlencode 'mode=fullpage' \
--data-urlencode 'device=mobile' \
--data-urlencode 'format=jpeg' \
-o hn-mobile.jpg -G点击后截图
# Open a "Show details" panel before capturing
curl 'https://api.crawlbase.com/screenshots?token=YOUR_JS_TOKEN' \
--data-urlencode 'url=https://example.com/product/123' \
--data-urlencode 'css_click_selector=button.show-details' \
--data-urlencode 'page_wait=1500' \
-o detail.png -G常见使用场景
- 链接预览:为缺少正确 meta 标签的站点生成 Open Graph 回退图。
- 视觉监控:每周抓取站点截图以检测布局回归。
- 合规归档:结合 Cloud Storage 归档某一特定日期页面的外观。
- 邮件报告:在定时报告中嵌入实时截图。

