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
async function getPage(batchId: string, page: number) {
const response = await fetch('https://crawlforge.dev/api/v1/tools/get_batch_results', {
method: 'POST',
headers: {
'X-API-Key': process.env.CRAWLFORGE_API_KEY!,
'Content-Type': 'application/json',
},
body: JSON.stringify({ batchId, page, limit: 25 }),
});
return response.json();
}
// Read total_pages from the first response, then loop — one fewer call than
// incrementing until you get an empty array.
const first = await getPage('batch_1700000000000_abc123def', 1);
if (first.success) {
const all = [...first.data.results];
for (let page = 2; page <= first.data.total_pages; page++) {
const next = await getPage(first.data.batch_id, page);
all.push(...next.data.results);
}
console.log(`Batch ${first.data.status}: ${all.length} of ${first.data.total} results`);
console.log('Credits remaining:', first.credits_remaining);
} else {
console.error('Error:', first.error);
}Python
get_batch_results.pyPython
import requests
import os
def get_page(batch_id, page):
response = requests.post(
'https://crawlforge.dev/api/v1/tools/get_batch_results',
headers={
'X-API-Key': os.environ['CRAWLFORGE_API_KEY'],
'Content-Type': 'application/json',
},
json={'batchId': batch_id, 'page': page, 'limit': 25}
)
return response.json()
# Read total_pages from the first response, then loop — one fewer call than
# incrementing until you get an empty list.
first = get_page('batch_1700000000000_abc123def', 1)
if first['success']:
all_results = list(first['data']['results'])
for page in range(2, first['data']['total_pages'] + 1):
nxt = get_page(first['data']['batch_id'], page)
all_results.extend(nxt['data']['results'])
print(f"Batch {first['data']['status']}: {len(all_results)} of {first['data']['total']} results")
print(f"Credits remaining: {first['credits_remaining']}")
else:
print(f"Error: {first['error']}")响应示例
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 开始构建。