> 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/custom-parser/parser-presets.md).

# Predefinições de parser

Você pode **salvar**, **reutilizar**, e **modificar** instruções de parsing personalizadas por meio da Web Scraper API. Depois que você criar um preset de parser, nós o hospedaremos em nosso sistema, permitindo que você o referencie em seus jobs de scraping via o `parser_preset` parâmetro no payload.

Este recurso oferece várias **capacidades principais**:

* Salve e gerencie seus próprios parsers em nosso sistema
* Reutilize facilmente presets em vários jobs de scraping
* Crie, recupere, atualize, exclua e liste todos os presets
* Acesse estatísticas de desempenho e uso de um preset
* Adapte-se a sites em mudança usando presets com self-healing

## Referência da API

**Endpoint:** `https://data.oxylabs.io/v1/parsers/presets`

A tabela lista cada operação disponível e o caminho do endpoint:

<table><thead><tr><th width="247.30859375">Ação</th><th width="152.23828125">Método da requisição</th><th>Caminho</th></tr></thead><tbody><tr><td><strong>Criar</strong> um preset</td><td><code>POST</code></td><td><code>/v1/parsers/presets</code></td></tr><tr><td><strong>Recuperar</strong> um preset</td><td><code>GET</code></td><td><code>/v1/parsers/presets/{preset_name}</code></td></tr><tr><td><strong>Atualizar</strong> um preset</td><td><code>PUT</code></td><td><code>/v1/parsers/presets/{preset_name}</code></td></tr><tr><td><strong>Excluir</strong> um preset</td><td><code>DELETE</code></td><td><code>/v1/parsers/presets/{preset_name}</code></td></tr><tr><td><strong>Listar todos</strong> presets</td><td><code>GET</code></td><td><code>/v1/parsers/presets</code></td></tr><tr><td><strong>Ver uso</strong> e <strong>desempenho</strong> estatísticas</td><td><code>GET</code></td><td><code>/v1/parsers/presets/{preset_name}/stats</code></td></tr><tr><td><strong>Acompanhar alterações de self-healing</strong> alterações</td><td><code>GET</code></td><td><code>/v1/parsers/presets/{parser_name}/changelog</code></td></tr></tbody></table>

## Ativar self-healing

Os presets de parser vêm com a função de self-healing, que ajuda a manter os parsers e suas taxas de sucesso conforme os sites mudam. Quando ativados, os presets de parser **se reparam automaticamente** e ajustam as instruções de parsing em segundo plano, sem entrada manual adicional.

Para **ativar self-healing** para o seu preset de Custom Parser, inclua os seguintes parâmetros obrigatórios ao criar ou atualizar um preset:

<table><thead><tr><th width="222.90234375">Parâmetro</th><th>Descrição</th></tr></thead><tbody><tr><td><code>self_heal</code></td><td>Ativa a funcionalidade de self-healing quando definido como <code>True</code>.</td></tr><tr><td><code>prompt_schema</code></td><td>Um schema JSON que descreve a saída necessária do parser. Você pode criar o schema automaticamente ao <a href="/pages/0a80d12dea5346dd06a78be3f06e88c705102ea0">gerar parsers com a API</a>.</td></tr><tr><td><code>urls</code></td><td>Uma lista de até 5 URLs do mesmo tipo de página. Recomendamos fornecer 3 a 5 URLs para ajudar o parser a se adaptar a diferentes layouts e melhorar a precisão do parsing.</td></tr></tbody></table>

<details>

<summary>Exemplo de payload</summary>

O exemplo de payload mostrado aqui ativa o self-healing ao atualizar um preset existente.

**Endpoint:** `PUT https://data.oxylabs.io/v1/parsers/presets/{preset_name}`

```json
{
    "self_heal": true,
    "urls": ["https://sandbox.oxylabs.io/products"],
    "prompt_schema": {
        "properties": {
            "product_titles": {
                "description": "Title of each product.",
                "items": {
                    "type": "string"
                },
                "maxItems": 5,
                "title": "Product Titles",
                "type": "array"
            }
        },
        "required": [
            "product_titles"
        ],
        "title": "Fields",
        "type": "object"
    }
}
```

</details>

## Exemplos de uso

### Criar um preset

**Endpoint:** `POST https://data.oxylabs.io/v1/parsers/presets`

**Payload:**

```json
{
    "name": "my_new_parser",
    "description": "Extract text from all H4 elements on the page.",
    "parsing_instructions": {
        "titles": {
            "_fns": [
                {
                    "_args": ["//h4/text()"],
                    "_fn": "xpath"
                }
            ]
        }
    }
}
```

<details>

<summary>Saída</summary>

```json
{
    "id": 421947,
    "name": "my_new_parser",
    "description": "Extract text from all H4 elements on the page.",
    "prompt_text": null,
    "prompt_schema": null,
    "urls": [],
    "render": false,
    "parsing_instructions": {
        "titles": {
            "_fns": [
                {
                    "_args": [
                        "//h4/text()"
                    ],
                    "_fn": "xpath"
                }
            ]
        }
    },
    "self_heal": false,
    "heal_status": "disabled",
    "last_healed_at": null,
    "created_at": "2025-10-27 11:40:22",
    "updated_at": "2025-10-27 11:40:22"
}
```

</details>

### Usar um preset

**Endpoint:** `POST https://realtime.oxylabs.io/v1/queries`

**Payload:**

```json
{
    "source": "universal",
    "url": "https://sandbox.oxylabs.io/products",
    "parse": true,
    "parser_preset": "my_new_parser"
}
```

<details>

<summary>Saída</summary>

```json
{
    "results": [
        {
            "content": {
                "titles": [
                    "The Legend of Zelda: Ocarina of Time",
                    "Super Mario Galaxy",
                    "Super Mario Galaxy 2",
                    "Metroid Prime",
                    "Super Mario Odyssey",
                    "Halo: Combat Evolved",
                    "The House in Fata Morgana - Dreams of the Revenants Edition -",
                    "NFL 2K1",
                    "Uncharted 2: Among Thieves",
                    "Tekken 3",
                    "The Legend of Zelda: The Wind Waker",
                    "Gran Turismo",
                    "Metal Gear Solid 2: Sons of Liberty",
                    "Grand Theft Auto Double Pack",
                    "Baldur's Gate II: Shadows of Amn",
                    "Tetris Effect: Connected",
                    "The Legend of Zelda Collector's Edition",
                    "Gran Turismo 3: A-Spec",
                    "The Legend of Zelda: A Link to the Past",
                    "The Legend of Zelda: Majora's Mask",
                    "The Last of Us",
                    "Persona 5 Royal",
                    "The Last of Us Remastered",
                    "The Legend of Zelda: Ocarina of Time 3D",
                    "Chrono Cross",
                    "Gears of War",
                    "Sid Meier's Civilization II",
                    "Halo 3",
                    "Ninja Gaiden Black",
                    "Super Mario Advance 4: Super Mario Bros. 3",
                    "Jet Grind Radio",
                    "Grim Fandango"
                ],
                "parse_status_code": 12000
            },
            "created_at": "2025-10-27 11:41:18",
            "updated_at": "2025-10-27 11:41:19",
            "page": 1,
            "url": "https://sandbox.oxylabs.io/products",
            "job_id": "7388540292158203905",
            "is_render_forced": false,
            "status_code": 200,
            "type": "parsed",
            "parser_type": "preset",
            "parser_preset": "my_new_parser"
        }
    ]
}
```

</details>

### Recuperar um preset

**Endpoint:** `GET https://data.oxylabs.io/v1/parsers/presets/{preset_name}`

<details>

<summary>Saída</summary>

```json
{
    "id": 421947,
    "name": "my_new_parser",
    "description": "Extract text from all H4 elements on the page.",
    "prompt_text": null,
    "prompt_schema": null,
    "urls": [],
    "render": false,
    "parsing_instructions": {
        "titles": {
            "_fns": [
                {
                    "_args": [
                        "//h4/text()"
                    ],
                    "_fn": "xpath"
                }
            ]
        }
    },
    "self_heal": false,
    "heal_status": "disabled",
    "last_healed_at": null,
    "created_at": "2025-10-27 11:40:22",
    "updated_at": "2025-10-27 11:40:22"
}
```

</details>

### Atualizar um preset

**Endpoint:** `PUT https://data.oxylabs.io/v1/parsers/presets/{preset_name}`

Defina os campos do preset que você deseja atualizar. No exemplo a seguir, apenas o `parsing_instructions` será atualizado.

**Payload:**

```json
{
    "parsing_instructions": {
        "titles": {
            "_fns": [
                {
                    "_args": ["//h4/text()"],
                    "_fn": "xpath"
                }
            ]
        },
        "prices": {
            "_fns": [
                {
                    "_args": [".price-wrapper"],
                    "_fn": "css"
                },
                {"_fn": "element_text"}
            ]
        }
    }
}
```

<details>

<summary>Saída</summary>

```json
{
    "id": 421947,
    "name": "my_new_parser",
    "description": "Extract text from all H4 elements on the page.",
    "prompt_text": null,
    "prompt_schema": null,
    "urls": [],
    "render": false,
    "parsing_instructions": {
        "prices": {
            "_fns": [
                {
                    "_args": [
                        ".price-wrapper"
                    ],
                    "_fn": "css"
                },
                {
                    "_fn": "element_text"
                }
            ]
        },
        "titles": {
            "_fns": [
                {
                    "_args": [
                        "//h4/text()"
                    ],
                    "_fn": "xpath"
                }
            ]
        }
    },
    "self_heal": false,
    "heal_status": "disabled",
    "last_healed_at": null,
    "created_at": "2025-10-27 11:40:22",
    "updated_at": "2025-10-27 11:44:24"
}
```

</details>

### Excluir um preset

**Endpoint:** `DELETE https://data.oxylabs.io/v1/parsers/presets/{preset_name}`

### Listar todos os presets

**Endpoint:** `GET https://data.oxylabs.io/v1/parsers/presets`

<details>

<summary>Saída</summary>

```json
[
    {
        "id": 421950,
        "name": "books_parser",
        "description": "Parses all book titles on the page.",
        "prompt_text": null,
        "prompt_schema": null,
        "urls": [],
        "render": false,
        "parsing_instructions": {
            "titles": {
                "_fns": [
                    {
                        "_args": [
                            "//h3//text()"
                        ],
                        "_fn": "xpath"
                    }
                ]
            }
        },
        "self_heal": false,
        "heal_status": "disabled",
        "last_healed_at": null,
        "created_at": "2025-10-27 11:46:59",
        "updated_at": "2025-10-27 11:46:59"
    },
    {
        "id": 421947,
        "name": "my_new_parser",
        "description": "Extract text from all H4 elements on the page.",
        "prompt_text": null,
        "prompt_schema": null,
        "urls": [],
        "render": false,
        "parsing_instructions": {
            "titles": {
                "_fns": [
                    {
                        "_args": [
                            "//h4/text()"
                        ],
                        "_fn": "xpath"
                    }
                ]
            }
        },
        "self_heal": false,
        "heal_status": "disabled",
        "last_healed_at": null,
        "created_at": "2025-10-27 11:40:22",
        "updated_at": "2025-10-27 11:45:20"
    }
]
```

</details>

### Ver estatísticas

**Endpoint:** `GET https://data.oxylabs.io/v1/parsers/presets/{preset_name}/stats`

<details>

<summary>Saída</summary>

```json
{
    "total_results": 9,
    "successful_results": 9,
    "success_rate": 100,
    "success_rate_by_path": {
        "titles": 100
    }
}
```

</details>

Você pode **filtrar resultados por data e hora** usando os `date_from` e/ou `date_to` parâmetros da URL. Use o formato `YYYY-MM-DDTHH`, onde `T` indica a hora, e `HH` é a hora em formato de 24 horas.

Por exemplo, para obter estatísticas das 9h às 14h em 5 de agosto de 2025:

```url
https://data.oxylabs.io/v1/parsers/presets/{preset_name}/stats?date_from=2025-08-05T9&date_to=2025-08-05T14
```

### Acompanhar alterações de self-healing

**Endpoint:** `GET https://data.oxylabs.io/v1/parsers/presets/{preset_name}/changelog`

Nosso sistema registra automaticamente a atividade de self-healing. Você pode acessar esse histórico para revisar todas as modificações feitas pela função de self-healing.


---

# 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 dynamically by asking a question.

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

```
GET https://developers.oxylabs.io/products/pt-br/web-scraper-api/features/custom-parser/parser-presets.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
