# 请求头、Cookie、方法

网页爬虫API通过使用我们团队预定义的标头和Cookie，最大限度地提高网站解除封锁的效率。如有需要，您可以定义自己的标头、Cookie和HTTP方法。

## 自定义标头

如果您需要使用自己的标头，可以通过添加以下内容来实现 `context:force_headers` 参数，并将其设置为 `true` 提交爬取任务时。网页爬虫API会将您的自定义标头与预定义标头集一起发送，然后使用它们访问网站。

#### 代码示例

```json
{
    "context": [
        {
            "key": "force_headers",
            "value": true
        },
        {
            "key": "headers",
            "value": {
                "Accept-Language": "en-US,en;q=0.5"
            }
        }
    ]
    "source": "universal",
    "url": "https://example.com",
}
```

## 自定义 Cookie

如果您需要使用自己的 Cookie，您可以通过添加 `context:force_Cookie` 参数，并将其设置为 `true` 提交爬取任务时。网页爬虫API会将您的自定义Cookie与预定义Cookie集一起发送，然后使用它们访问网站。如果您还想复用同一个代理IP地址，请查看 [代理会话](/products/cn/web-scraper-api/features/localization/proxy-location.md#sessions) 文档。

#### 代码示例

```json
{
    "context": [
        {
            "key": "force_Cookie",
            "value": true
        },
        {
            "key": "Cookie",
            "value": [
                {
                    "key": "NID", 
                    "value": "1234567890"
                }
            ]
        },
    ],
    "source": "universal",
    "url": "https://example.com",
}
```

## HTTP方法

`通用` 源默认使用 `GET` HTTP方法。

如果您需要将数据发布到目标网站，则必须将HTTP方法设置为 `POST` 并提供一个经过Base64编码的 `POST` 请求正文。

**代码示例**

```json
[
    {
        "key": "http_method",
        "value": "post"
    },
    {
        "key": "content",
        "value": "base64EncodedPOSTBody"
    }
]
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.oxylabs.io/products/cn/web-scraper-api/features/http-context-and-job-management/headers-cookies-method.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
