get_batch_results
分页获取 batch_scrape 任务的结果。提交一次批量任务,然后用返回的 batchId 轮询此端点,查看状态并随着任务完成逐页取回结果。
使用场景
轮询运行中的批量任务
在批量任务其余部分仍在运行时,查看任务状态并取回已经完成的页面。
翻阅大型任务
每次 25 条(每页最多 100 条)地翻阅结果,无需把整个批量任务保存在内存中。
重启后恢复
batchId 的生命周期长于你的进程——崩溃的 worker 可以精确地从中断处继续。
低成本状态检查
每次调用 1 credit,轮询的成本只是重跑那个你已经付过费的批量任务的零头。
Endpoint
POST
/api/v1/tools/get_batch_resultsAuth Required
Free 计划 1 req/s
1 credit
Parameters
batchId 来自 batch_scrape 的响应——本工具从不启动任务,只负责读回结果。| Name | Type | Required | Default | Description |
|---|---|---|---|---|
batchId | string | Required | - | 由 `batch_scrape` 返回的批量任务标识符。 Example: batch_1700000000000_abc123def |
page | number | Optional | 1 | 要获取的页码(从 1 开始)。 Example: 1 |
limit | number | Optional | 25 | 每页结果数(1-100)。 Example: 50 |
请求示例
cURL
terminalBash
curl -X POST https://crawlforge.dev/api/v1/tools/get_batch_results \
-H "X-API-Key: cf_test_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"batchId": "batch_1700000000000_abc123def",
"page": 1,
"limit": 25
}'TypeScript
getBatchResults.tsTypescript
// npm install crawlforge-sdk
import { CrawlForge } from 'crawlforge-sdk';
const client = new CrawlForge({ apiKey: process.env.CRAWLFORGE_API_KEY });
// Read total_pages from the first response, then loop — one fewer call than
// incrementing until you get an empty array.
const first = await client.getBatchResults({
batchId: 'batch_1700000000000_abc123def',
page: 1,
limit: 25,
});
// result.data is untyped in crawlforge-sdk 0.1 — its shape is the Response Example below.
type BatchPage = {
batch_id: string;
status: string;
total: number;
total_pages: number;
results: { url: string; status: string }[];
};
const { batch_id, status, total, total_pages, results } = first.data as BatchPage;
const all = [...results];
for (let page = 2; page <= total_pages; page++) {
const next = await client.getBatchResults({ batchId: batch_id, page, limit: 25 });
all.push(...(next.data as BatchPage).results);
}
console.log('Batch ' + status + ': ' + all.length + ' of ' + total + ' results');
console.log('Credits remaining:', first.creditsRemaining);Python
get_batch_results.pyPython
# pip install crawlforge
from crawlforge import CrawlForge
client = CrawlForge() # reads CRAWLFORGE_API_KEY
# Read total_pages from the first response, then loop — one fewer call than
# incrementing until you get an empty list.
first = client.get_batch_results(batchId='batch_1700000000000_abc123def', page=1, limit=25)
# result.data is a plain dict — its shape is the Response Example below.
batch = first.data
all_results = list(batch['results'])
for page in range(2, batch['total_pages'] + 1):
nxt = client.get_batch_results(batchId=batch['batch_id'], page=page, limit=25)
all_results.extend(nxt.data['results'])
print(f"Batch {batch['status']}: {len(all_results)} of {batch['total']} results")
print(f"Credits remaining: {first.credits_remaining}")响应示例
200 OK96ms
{ "success": true, "data": { "batch_id": "batch_1700000000000_abc123def", "status": "completed", "page": 1, "limit": 25, "total": 3, "total_pages": 1, "results": [ { "url": "https://example.com/page-1", "status": "completed", "data": { "title": "Example page 1" } }, { "url": "https://example.com/page-2", "status": "completed", "data": { "title": "Example page 2" } } ] }, "credits_used": 1, "credits_remaining": 999, "processing_time": 96}Field Descriptions
data.batch_id回显你查询的批量任务data.status批量任务整体的状态data.total所有页面的结果总数data.total_pages在当前 `limit` 下共有多少页data.results本页每个 URL 一条记录,各自带有独立的 `status`credits_used本次请求扣除的 credits(每次获取 1 credit)credits_remaining你剩余的 credits 余额错误处理
输入无效(400 Bad Request)
batchId 为空、page 小于 1,或 limit 超出 1-100 范围。
获取失败(500 Internal Server Error)
无法读回该批量任务——最常见的原因是 batchId 未知或已过期。获取失败不扣除 credits。
credits 不足(402 Payment Required)
你的账户 credits 不足。购买更多 credits 或升级你的计划。
超出速率限制(429 Too Many Requests)
你已超出所在计划的速率限制。稍等片刻,或升级你的计划以获得更高上限。
专业提示: 从第一次响应中读取
total_pages 再循环取完,不要一直递增 page 直到拿到空数组——这样每个批量任务能少发一次请求。credits 成本
1 credit
每次请求 1 credit
每次 get_batch_results 请求扣除 1 credit,无论你取回 1 条还是 100 条结果。抓取本身已由
batch_scrape 计费。Free 计划: 1,000 个一次性 credits = 1,000 次请求
Hobby 计划: 每月 5,000 credits = 5,000 次请求(19 美元/月)
Professional 计划: 每月 50,000 credits = 50,000 次请求(99 美元/月)
Business 计划: 每月 250,000 credits = 250,000 次请求(399 美元/月)
相关工具
准备好试用 get_batch_results 了吗?免费注册,获得 1,000 credits 开始构建。