跳转到主要内容
POST
/
datasets
/
v3
/
scrape
抓取数据并直接在响应中返回。
curl --request POST \
  --url https://api.brightdata.com/datasets/v3/scrape \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "input": [
    {
      "url": "www.linkedin.com/in/bulentakar"
    }
  ],
  "custom_output_fields": "url|about.updated_on"
}
'
"OK"

工作原理

此同步 API 端点允许用户在发送抓取请求时,实时直接在响应中获取结果,例如在终端或应用程序中,无需外部存储或手动下载。此方式通过消除额外的结果获取步骤,使数据采集过程更加高效。 你可以使用 format 参数指定所需的输出格式。如果未提供格式,响应将默认使用 JSON。

超时限制

请注意,此同步请求受 1 分钟超时限制。如果数据获取过程超过此限制,API 将返回 HTTP 202 响应,表示请求仍在处理中。在这种情况下,你将收到一个快照 ID,可通过“监控快照(Monitor Snapshot)”和“下载快照(Download Snapshot)”端点以异步方式监控并获取结果。 超时情况下的示例响应:
202
{
  "snapshot_id": "s_xxx",
  "message": "Your request is still in progress and cannot be retrieved in this call. Use the provided Snapshot ID to track progress via the Monitor Snapshot endpoint and download it once ready via the Download Snapshot endpoint."
}

授权

Authorization
string
header
必填

在 Authorization 头中使用您的 Bright Data API Key 作为 Bearer token。

认证方法:

  1. 从 Bright Data 账户设置获取您的 API Key: https://brightdata.com/cp/setting/users
  2. 在请求的 Authorization 头中包含 API Key
  3. 格式: Authorization: Bearer YOUR_API_KEY

示例:

Authorization: Bearer b5648e1096c6442f60a6c4bbbe73f8d2234d3d8324554bd6a7ec8f3f251f07df

了解如何获取 Bright Data API Key: https://docs.brightdata.com/cn/api-reference/authentication#如何生成新的-api-key?

查询参数

dataset_id
string
必填

触发数据采集的数据集 ID

custom_output_fields
string

输出列列表,用 | 分隔(例如:url|about.updated_on)。仅包含指定字段的响应。

示例:

"url|about.updated_on"

include_errors
boolean

在结果中包含错误报告

format
enum<string>
默认值:json

指定响应格式(默认: ndjson)

可用选项:
ndjson,
json,
csv

请求体

application/json
input
object[]
必填

要抓取的输入项列表。

custom_output_fields
string

输出列列表,用 | 分隔(例如,url|about.updated_on)。筛选响应,仅包含指定字段。

示例:

"url|about.updated_on"

响应

成功

The response is of type string.

示例:

"OK"