> ## Documentation Index
> Fetch the complete documentation index at: https://brightdata-ipv6-release.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 触发抓取工具，进行批量采集

**API 端点:** `POST` `/dca/trigger?collector={ID_COLLECTOR}`

## `POST` Body

<ParamField body="Authorization" type="字符串" 必填项>
  raw JSON `-d '[{"url":"https://targetwebsite.com/product_id/"}]'`
</ParamField>

## 查询参数

<ParamField query="collector" type="字符串" 必填项>
  抓取工具的唯一标识
</ParamField>

<ParamField query="version" type="字符串">
  设置为 `dev` 以触发抓取工具的开发版本
</ParamField>

<ParamField query="name" type="字符串">
  `human_name` - 批量采集的数据名称，须易于识别和理解
</ParamField>

### 选择 `trigger_behavior` 参数：

<ParamField query="queue_next" type="整数" default="1">
  {  /* TODO: Need more info on this? Does 1 means True and 0 means False? */}

  如果抓取队列中已有任务，则将该作业推送至队列中
</ParamField>

<ParamField query="queue" type="字符串">
  发送另一批请求，这些请求将在上一批请求完成后开始处理
</ParamField>

<ParamField query="confirm_cancel" type="整数" default="1">
  {  /* TODO: Need more info on this? Does 1 means True and 0 means False? */}

  取消正在运行的作业，然后提交并运行新的请求
</ParamField>

<ParamField query="no_downloads" type="整数" default="1">
  {  /* TODO: Need more info on this? Does 1 means True and 0 means False? */}

  禁止下载媒体文件
</ParamField>

<ParamField query="deadline" type="字符串" placeholder="1h">
  设置作业截止时间，作业将在指定时间后终止

  * h：小时
  * m：分钟
  * s：秒
</ParamField>

## 标头

<ParamField header="Authorization" type="字符串" 必填项>
  授权持有者密钥 `-H "Authorization: Bearer API_TOKEN"`
</ParamField>

<ParamField header="Content-Type" type="字符串" 必填项>
  JSON/CSV/Multipart `-H "Content-Type: application/json"`
</ParamField>

<ResponseExample>
  ```json Sample Response theme={null}
  {
   "collection_id": "ID_DATASET",
   "start_eta": "2021-11-07T13:26:22.702Z"
  }
  ```
</ResponseExample>

<RequestExample>
  ```sh Shell theme={null}
  curl "https://api.brightdata.com/dca/trigger?collector=ID_COLLECTOR&queue_next=1" -H "Content-Type: application/json" -H "Authorization: Bearer API_TOKEN" -d '[{"url":"https://targetwebsite.com/product_id/"}]'
  ```

  ```js NodeJS theme={null}
  #!/usr/bin/env node
  require('request-promise')({
   method: 'POST',
   url: 'https://api.brightdata.com/dca/trigger?collector=ID_COLLECTOR&queue_next=1',
   json: [{'url': 'https://targetwebsite.com/product_id/'}],
   headers: {'Authorization': 'Bearer API_TOKEN'},
  }).then(function(data){ console.log(data); },
   function(err){ console.error(err); });
  ```

  ```java Java theme={null}
  package example;
  import org.apache.http.HttpHost;
  import org.apache.http.client.fluent.\*;
  public class Example {
   public static void main(String[] args) throws Exception {  
   String body = "[{\"url\":\"https://targetwebsite.com/product_id/\"}]";
   String res = Executor.newInstance()
   .addHeader("Authorization", "Bearer API_TOKEN")  
   .execute(Request.Post("https://api.brightdata.com/dca/trigger?collector=ID_COLLECTOR&queue_next=1"))  
   .bodyString(body, ContentType.APPLICATION_JSON))  
   .returnContent().asString();  
   System.out.println(res)
   }  
  }
  ```

  ```cs C# theme={null}
  using System;
  using System.Net;
  using System.Net.Http;
  using System.Net.Http.Headers;
  public class Program {
   public static async Task Main() {
   var client = new HttpClient();
   var requestMessage = new HttpRequestMessage {
   Method = HttpMethod.Post,  
   RequestUri = new Uri("https://api.brightdata.com/dca/trigger?collector=ID_COLLECTOR&queue_next=1"),
   Headers = {
   {"Authorization", "Bearer API_TOKEN"}
   },  
   Content = new StringContent(JsonConvert.SerializeObject([  
   new {  
   url = "https://targetwebsite.com/product_id/"  
   }  
   ]), Encoding.UTF8, "application/json"))
   };
   var response = await client.SendAsync(requestMessage);
   var responseString = await response.Content.ReadAsStringAsync();
   Console.WriteLine(responseString);
   }
  }
  ```

  ```python Python theme={null}
  #!/usr/bin/env python
  print('If you get error "ImportError: No module named requests", please install it:\n$ sudo pip install requests');
  import requests
    
  data = [{'url': 'https://targetwebsite.com/product_id/'}]
  headers = {'Content-Type': 'application/json','Authorization': 'Bearer API_TOKEN'}
  r = requests.post('https://api.brightdata.com/dca/trigger?collector=ID_COLLECTOR&queue_next=1', data=data, headers=headers)
  print(r.content)
  ```
</RequestExample>
