同步触发爬虫进行实时数据采集
触发同步实时 Scraper Studio 采集。POST /dca/crawl 会保持请求打开,直到爬虫完成或达到超时,然后以 JSON 形式直接返回数据。
timeout,然后以 JSON 形式直接返回采集到的数据。这与异步实时端点不同,后者会立即返回一个 response_id。
超时行为
timeout 查询参数的取值必须在 25s 到 50s 之间。
- 如果爬虫在超时时间内完成,响应返回
200 OK以及采集到的数据。 - 如果到达超时时爬虫仍在运行,响应返回
202 Accepted以及一个response_id。使用该response_id调用实时数据端点以异步方式获取结果。
何时使用同步实时
在以下情况下使用同步实时(POST /dca/crawl):
- 你需要在同一个 HTTP 请求中获得结果。
- 你只发送单个输入。
- 你的客户端可以保持请求打开,直到采集完成。
- 采集通常在配置的超时时间内完成。
POST /dca/trigger_immediate):
- 你希望先触发采集,稍后再获取结果。
- 你不希望保持 HTTP 请求处于打开状态。
- 你需要在一次运行中处理多个输入。
授权
Use your Bright Data API Key as a Bearer token in the Authorization header.
How to authenticate:
- Obtain your API Key from the Bright Data account settings at https://brightdata.com/cp/setting/users
- Include the API Key in the Authorization header of your requests
- Format:
Authorization: Bearer YOUR_API_KEY
Example:
Learn how to get your Bright Data API key: https://docs.brightdata.com/api-reference/authentication
查询参数
A unique identification of the collector to run
"c_abc123"
How long the request stays open while waiting for the result. Must be between 25s and 50s. If the scraper finishes within the timeout, the response returns 200 OK with the collected data. If the scraper is still running when the timeout is reached, the response returns 202 Accepted with a response_id.
"50s"
Set to dev to trigger the development version of the scraper
请求体
A single input object. The fields must match the input schema defined for the collector. A URL-based scraper may require url, while a search scraper may require fields such as keyword and location.
Single input object whose fields match the collector input schema.
Example field for collectors that take a target URL. Replace with the fields your collector expects.
响应
OK