> For the complete documentation index, see [llms.txt](https://developers.oxylabs.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.oxylabs.io/products/pt-br/web-scraper-api/features/result-processing-and-storage/output-types/capturing-network-requests-fetch-xhr.md).

# Captura de requisições de rede (Fetch/XHR)

Capture a atividade de rede da Web Scraper API usando a flag XHR. Recupere todas as requisições Fetch/XHR feitas durante o carregamento da página como JSON estruturado para facilitar a extração de dados.

Às vezes, é mais conveniente extrair os dados necessários de uma ou mais das requisições Fetch/XHR que um navegador faz ao carregar a página da web, em vez de analisar o HTML.

Web Scraper API suporta retornar a lista de requisições XHR feitas ao carregar a página da web.

### Uso

Para obter uma lista de requisições XHR na resposta, inclua a `"xhr": true` flag como no exemplo de payload abaixo. A renderização de JavaScript é necessária (`render` deve ser definido; sem isso a requisição é rejeitada). Quando `xhr` está definido, a lista de XHR se torna a saída padrão do job; adicione `?type=raw,xhr` ao endpoint para receber o HTML também.

```json
{
    "source": "universal",
    "url": "https://petstore.swagger.io/",
    "render": "html",
    "xhr": true
}
```

A resposta conterá uma lista de objetos JSON, cada um representando uma única requisição XHR.

```json
{
    "results": [
        {
            "content": [
                {
                    "url": "https://petstore.swagger.io/v2/swagger.json",
                    "method": "GET",
                    "status_code": 200,
                    "response_body": "{\"swagger\":\"2.0\",\"info\":{\"description\":\"This is a sample server Petstore server.  You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). ...","t_0529f6a6":"request_headers": {
                    "request_headers": {
                        "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
                        "accept-encoding": "gzip, deflate, br, zstd",
                        "priority": "u=0, i",
                        "referer": "https://petstore.swagger.io/",
                        "save-data": "on",
                        "sec-ch-ua": "\"Chromium\";v=\"136\", \"Microsoft Edge\";v=\"136\", \"Not.A/Brand\";v=\"99\"",
                        "sec-ch-ua-mobile": "?0",
                        "sec-ch-ua-platform": "\"macOS\"",
                        "sec-fetch-dest": "document",
                        "sec-fetch-mode": "navigate",
                        "sec-fetch-site": "none",
                        "sec-fetch-user": "?1",
                        "upgrade-insecure-requests": "1",
                        "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36 Edg/136.0.0.0"
                    },
                    "request_payload": null,
                    "response_headers": {
                        "access-control-allow-headers": "Content-Type, api_key, Authorization",
                        "access-control-allow-methods": "GET, POST, DELETE, PUT",
                        "access-control-allow-origin": "*",
                        "content-type": "application/json",
                        "date": "Mon, 14 Sep 2026 11:12:15 GMT",
                        "server": "Jetty(9.2.9.v20150224)"
                    }
                }
            ],
            "created_at": "2026-09-14 11:12:07",
            "updated_at": "2026-09-14 11:12:20",
            "page": 1,
            "url": "https://petstore.swagger.io/",
            "job_id": "7505221841498163201",
            "status_code": 200,
            "type": "xhr"
        }
    ],
    "job": {...}
}
```

| **Chave de saída** | **Descrição**                                                        | **Tipo**             |
| ------------------ | -------------------------------------------------------------------- | -------------------- |
| `url`              | URL completa da requisição XHR                                       | cadeia de caracteres |
| `status_code`      | Código de status HTTP da resposta                                    | inteiro              |
| `method`           | Método HTTP usado para a requisição                                  | cadeia de caracteres |
| `request_headers`  | Pares de chave-valor de **requisição** cabeçalhos, incluindo cookies | objeto               |
| `response_headers` | Pares de chave-valor de **response** cabeçalhos, incluindo cookies   | objeto               |
| `request_payload`  | Payload (inclua esta chave apenas com requisições POST, PUT, PATCH)  | cadeia de caracteres |
| `response_body`    | Corpo da resposta                                                    | cadeia de caracteres |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developers.oxylabs.io/products/pt-br/web-scraper-api/features/result-processing-and-storage/output-types/capturing-network-requests-fetch-xhr.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
