Pular para conteúdo

PARSE_STRUCTURED - Extração Estruturada de HTML

O que é este Node?

O PARSE_STRUCTURED é o node responsável por extrair a estrutura organizada de documentos HTML, separando títulos, parágrafos, listas e tabelas em um formato JSON estruturado e fácil de processar.

Por que este Node existe?

HTML mistura conteúdo e estrutura de forma complexa. O PARSE_STRUCTURED existe para:

  1. Organização: Separar diferentes tipos de conteúdo (headings, parágrafos, listas, tabelas) de forma estruturada
  2. Análise: Facilitar processamento automatizado de documentos HTML complexos
  3. Navegação: Permitir acesso programático a partes específicas de um documento
  4. Indexação: Preparar conteúdo HTML para indexação e busca estruturada

Como funciona internamente?

Quando o PARSE_STRUCTURED é executado, o sistema:

  1. Carrega o HTML: Usa Cheerio para parsear o documento HTML
  2. Limpa o conteúdo: Remove scripts, estilos e elementos de navegação
  3. Extrai título: Busca em <title> ou primeiro <h1>
  4. Coleta headings: Extrai todos os h1-h6 com nível hierárquico e id
  5. Captura parágrafos: Extrai parágrafos relevantes (> 20 caracteres)
  6. Processa listas: Extrai listas (ul/ol) com seus itens
  7. Analisa tabelas: Extrai tabelas com headers e rows
  8. Retorna JSON: Converte tudo para objeto JSON estruturado

Código interno (html-parser-executor.service.ts:305-374):

private parseStructured($: CheerioAPI, config: HTMLParserNodeData): any {
  const structure: any = {
    title: $('title').text().trim() || $('h1').first().text().trim(),
    headings: [],
    paragraphs: [],
    lists: [],
    tables: []
  };

  // Extract headings hierarchy
  $('h1, h2, h3, h4, h5, h6').each((index, element) => {
    const level = parseInt(element.tagName.substring(1));
    const text = $(element).text().trim();
    if (text) {
      structure.headings.push({
        level,
        text,
        id: $(element).attr('id')
      });
    }
  });

  // Extract paragraphs
  $('p').each((index, element) => {
    const text = $(element).text().trim();
    if (text.length > 20) { // Only meaningful paragraphs
      structure.paragraphs.push(text);
    }
  });

  // Extract lists
  $('ul, ol').each((index, element) => {
    const listItems: string[] = [];
    $(element).find('> li').each((i, li) => {
      listItems.push($(li).text().trim());
    });
    if (listItems.length > 0) {
      structure.lists.push({
        type: element.tagName,
        items: listItems
      });
    }
  });

  // Extract tables
  $('table').each((index, element) => {
    const headers: string[] = [];
    const rows: string[][] = [];

    $(element).find('thead th').each((i, th) => {
      headers.push($(th).text().trim());
    });

    $(element).find('tbody tr').each((i, tr) => {
      const row: string[] = [];
      $(tr).find('td').each((j, td) => {
        row.push($(td).text().trim());
      });
      if (row.length > 0) {
        rows.push(row);
      }
    });

    if (headers.length > 0 || rows.length > 0) {
      structure.tables.push({ headers, rows });
    }
  });

  return structure;
}

Quando você DEVE usar este Node?

Use PARSE_STRUCTURED sempre que precisar de acessar partes específicas de um documento HTML:

Casos de uso

  1. Extração de documentação: "Extrair índice de uma página de docs (todos os headings)"
  2. Análise de conteúdo: "Separar e contar parágrafos de artigos para métricas"
  3. Processamento de tabelas: "Extrair dados tabulares de relatórios HTML"
  4. Indexação semântica: "Criar índice estruturado de documentos para busca"

Quando NÃO usar PARSE_STRUCTURED

  • Precisa apenas texto: Use parse_text para conteúdo simples sem estrutura
  • Precisa Markdown: Use parse_markdown para converter e manter formatação
  • Precisa elementos específicos: Use parse_custom com seletores CSS personalizados

Parâmetros Detalhados

inputVariable (string, obrigatório)

O que é: Nome da variável que contém o HTML a ser analisado estruturalmente.

Padrão: "html_content"

Flow completo para testar:

{
  "name": "Teste HTML Parser - Parse Structured Input",
  "nodes": [
    {
      "id": "start_1",
      "type": "start",
      "position": { "x": 100, "y": 100 },
      "data": { "label": "Início" }
    },
    {
      "id": "variable_1",
      "type": "variable",
      "position": { "x": 300, "y": 100 },
      "data": {
        "label": "Documento HTML",
        "parameters": {
          "variableName": "documento",
          "variableValue": "<html><head><title>Meu Doc</title></head><body><h1>Título Principal</h1><p>Parágrafo com mais de vinte caracteres de conteúdo.</p><h2>Subtítulo</h2><ul><li>Item 1</li><li>Item 2</li></ul></body></html>"
        }
      }
    },
    {
      "id": "parser_1",
      "type": "html_parser",
      "position": { "x": 500, "y": 100 },
      "data": {
        "label": "Extrair Estrutura",
        "parameters": {
          "inputVariable": "documento",
          "parseMode": "structured",
          "outputVariable": "estrutura"
        }
      }
    },
    {
      "id": "message_1",
      "type": "message",
      "position": { "x": 700, "y": 100 },
      "data": {
        "label": "Mostrar",
        "parameters": {
          "message": "Estrutura:\n{{estrutura}}"
        }
      }
    },
    {
      "id": "end_1",
      "type": "end",
      "position": { "x": 900, "y": 100 },
      "data": { "label": "Fim" }
    }
  ],
  "edges": [
    { "source": "start_1", "target": "variable_1" },
    { "source": "variable_1", "target": "parser_1" },
    { "source": "parser_1", "target": "message_1" },
    { "source": "message_1", "target": "end_1" }
  ]
}

Teste: Esperado: JSON com title, headings, paragraphs e lists estruturados

parseMode (string, obrigatório)

O que é: Modo de parsing. Para PARSE_STRUCTURED, deve ser "structured".

Padrão: "text"

Flow completo para testar:

{
  "name": "Teste HTML Parser - Modo Structured",
  "nodes": [
    {
      "id": "start_1",
      "type": "start",
      "position": { "x": 100, "y": 100 },
      "data": { "label": "Início" }
    },
    {
      "id": "variable_1",
      "type": "variable",
      "position": { "x": 300, "y": 100 },
      "data": {
        "label": "HTML com Tabela",
        "parameters": {
          "variableName": "html_tabela",
          "variableValue": "<table><thead><tr><th>Nome</th><th>Idade</th></tr></thead><tbody><tr><td>João</td><td>25</td></tr><tr><td>Maria</td><td>30</td></tr></tbody></table>"
        }
      }
    },
    {
      "id": "parser_1",
      "type": "html_parser",
      "position": { "x": 500, "y": 100 },
      "data": {
        "label": "Parse Estruturado",
        "parameters": {
          "inputVariable": "html_tabela",
          "parseMode": "structured",
          "outputVariable": "dados"
        }
      }
    },
    {
      "id": "message_1",
      "type": "message",
      "position": { "x": 700, "y": 100 },
      "data": {
        "label": "Ver Dados",
        "parameters": {
          "message": "{{dados}}"
        }
      }
    },
    {
      "id": "end_1",
      "type": "end",
      "position": { "x": 900, "y": 100 },
      "data": { "label": "Fim" }
    }
  ],
  "edges": [
    { "source": "start_1", "target": "variable_1" },
    { "source": "variable_1", "target": "parser_1" },
    { "source": "parser_1", "target": "message_1" },
    { "source": "message_1", "target": "end_1" }
  ]
}

Teste: Esperado: JSON com arrays tables contendo headers e rows

outputVariable (string, opcional)

O que é: Variável onde será armazenado o JSON estruturado.

Padrão: "parsed_content"

Flow completo para testar:

{
  "name": "Teste HTML Parser - Output Structured",
  "nodes": [
    {
      "id": "start_1",
      "type": "start",
      "position": { "x": 100, "y": 100 },
      "data": { "label": "Início" }
    },
    {
      "id": "variable_1",
      "type": "variable",
      "position": { "x": 300, "y": 100 },
      "data": {
        "label": "HTML Listas",
        "parameters": {
          "variableName": "html",
          "variableValue": "<div><h1>Título</h1><ol><li>Primeiro</li><li>Segundo</li><li>Terceiro</li></ol></div>"
        }
      }
    },
    {
      "id": "parser_1",
      "type": "html_parser",
      "position": { "x": 500, "y": 100 },
      "data": {
        "label": "Estruturar",
        "parameters": {
          "inputVariable": "html",
          "parseMode": "structured",
          "outputVariable": "doc_estrutura"
        }
      }
    },
    {
      "id": "message_1",
      "type": "message",
      "position": { "x": 700, "y": 100 },
      "data": {
        "label": "Exibir",
        "parameters": {
          "message": "Listas: {{doc_estrutura.lists}}"
        }
      }
    },
    {
      "id": "end_1",
      "type": "end",
      "position": { "x": 900, "y": 100 },
      "data": { "label": "Fim" }
    }
  ],
  "edges": [
    { "source": "start_1", "target": "variable_1" },
    { "source": "variable_1", "target": "parser_1" },
    { "source": "parser_1", "target": "message_1" },
    { "source": "message_1", "target": "end_1" }
  ]
}

Teste: Esperado: Array com objeto {type: "ol", items: [...]}

removeScripts (boolean, opcional)

O que é: Remove tags de script antes de processar estrutura.

Padrão: true

Flow completo para testar:

{
  "name": "Teste HTML Parser - Remove Scripts Structured",
  "nodes": [
    {
      "id": "start_1",
      "type": "start",
      "position": { "x": 100, "y": 100 },
      "data": { "label": "Início" }
    },
    {
      "id": "variable_1",
      "type": "variable",
      "position": { "x": 300, "y": 100 },
      "data": {
        "label": "HTML",
        "parameters": {
          "variableName": "html",
          "variableValue": "<div><h1>Conteúdo</h1><script>alert('x');</script><p>Texto importante aqui com mais de vinte caracteres.</p></div>"
        }
      }
    },
    {
      "id": "parser_1",
      "type": "html_parser",
      "position": { "x": 500, "y": 100 },
      "data": {
        "label": "Parse Limpo",
        "parameters": {
          "inputVariable": "html",
          "parseMode": "structured",
          "removeScripts": true,
          "outputVariable": "limpo"
        }
      }
    },
    {
      "id": "message_1",
      "type": "message",
      "position": { "x": 700, "y": 100 },
      "data": {
        "label": "Ver",
        "parameters": {
          "message": "{{limpo}}"
        }
      }
    },
    {
      "id": "end_1",
      "type": "end",
      "position": { "x": 900, "y": 100 },
      "data": { "label": "Fim" }
    }
  ],
  "edges": [
    { "source": "start_1", "target": "variable_1" },
    { "source": "variable_1", "target": "parser_1" },
    { "source": "parser_1", "target": "message_1" },
    { "source": "message_1", "target": "end_1" }
  ]
}

Teste: Esperado: Estrutura sem script, apenas heading e parágrafo

removeStyles (boolean, opcional)

O que é: Remove styles e atributos de estilo antes de processar.

Padrão: true

Flow completo para testar:

{
  "name": "Teste HTML Parser - Remove Styles Structured",
  "nodes": [
    {
      "id": "start_1",
      "type": "start",
      "position": { "x": 100, "y": 100 },
      "data": { "label": "Início" }
    },
    {
      "id": "variable_1",
      "type": "variable",
      "position": { "x": 300, "y": 100 },
      "data": {
        "label": "HTML Styled",
        "parameters": {
          "variableName": "styled",
          "variableValue": "<div><h2 style='color:blue'>Seção</h2><style>.x { margin: 0; }</style><p>Parágrafo de exemplo com conteúdo suficiente.</p></div>"
        }
      }
    },
    {
      "id": "parser_1",
      "type": "html_parser",
      "position": { "x": 500, "y": 100 },
      "data": {
        "label": "Estruturar",
        "parameters": {
          "inputVariable": "styled",
          "parseMode": "structured",
          "removeStyles": true,
          "outputVariable": "estrut"
        }
      }
    },
    {
      "id": "message_1",
      "type": "message",
      "position": { "x": 700, "y": 100 },
      "data": {
        "label": "Resultado",
        "parameters": {
          "message": "{{estrut}}"
        }
      }
    },
    {
      "id": "end_1",
      "type": "end",
      "position": { "x": 900, "y": 100 },
      "data": { "label": "Fim" }
    }
  ],
  "edges": [
    { "source": "start_1", "target": "variable_1" },
    { "source": "variable_1", "target": "parser_1" },
    { "source": "parser_1", "target": "message_1" },
    { "source": "message_1", "target": "end_1" }
  ]
}

Teste: Esperado: Estrutura sem informações de style

O que é: Extrai lista de links e inclui em metadata.

Padrão: false

Flow completo para testar:

{
  "name": "Teste HTML Parser - Links Structured",
  "nodes": [
    {
      "id": "start_1",
      "type": "start",
      "position": { "x": 100, "y": 100 },
      "data": { "label": "Início" }
    },
    {
      "id": "variable_1",
      "type": "variable",
      "position": { "x": 300, "y": 100 },
      "data": {
        "label": "HTML com Links",
        "parameters": {
          "variableName": "html",
          "variableValue": "<div><h1>Recursos</h1><p>Visite <a href='https://doc1.com'>Doc 1</a> e <a href='https://doc2.com'>Doc 2</a>.</p></div>"
        }
      }
    },
    {
      "id": "parser_1",
      "type": "html_parser",
      "position": { "x": 500, "y": 100 },
      "data": {
        "label": "Parse com Links",
        "parameters": {
          "inputVariable": "html",
          "parseMode": "structured",
          "extractLinks": true,
          "outputVariable": "estrut",
          "metadataVariable": "meta"
        }
      }
    },
    {
      "id": "message_1",
      "type": "message",
      "position": { "x": 700, "y": 100 },
      "data": {
        "label": "Ver",
        "parameters": {
          "message": "Estrutura: {{estrut}}\n\nLinks: {{meta.links}}"
        }
      }
    },
    {
      "id": "end_1",
      "type": "end",
      "position": { "x": 900, "y": 100 },
      "data": { "label": "Fim" }
    }
  ],
  "edges": [
    { "source": "start_1", "target": "variable_1" },
    { "source": "variable_1", "target": "parser_1" },
    { "source": "parser_1", "target": "message_1" },
    { "source": "message_1", "target": "end_1" }
  ]
}

Teste: Esperado: Estrutura + array com ["https://doc1.com", "https://doc2.com"]

extractImages (boolean, opcional)

O que é: Extrai lista de imagens (src) do documento.

Padrão: false

Flow completo para testar:

{
  "name": "Teste HTML Parser - Images Structured",
  "nodes": [
    {
      "id": "start_1",
      "type": "start",
      "position": { "x": 100, "y": 100 },
      "data": { "label": "Início" }
    },
    {
      "id": "variable_1",
      "type": "variable",
      "position": { "x": 300, "y": 100 },
      "data": {
        "label": "HTML com Imagens",
        "parameters": {
          "variableName": "html",
          "variableValue": "<article><h1>Galeria</h1><img src='foto1.jpg' alt='Foto 1'><img src='foto2.jpg' alt='Foto 2'></article>"
        }
      }
    },
    {
      "id": "parser_1",
      "type": "html_parser",
      "position": { "x": 500, "y": 100 },
      "data": {
        "label": "Parse com Imagens",
        "parameters": {
          "inputVariable": "html",
          "parseMode": "structured",
          "extractImages": true,
          "outputVariable": "estrut",
          "metadataVariable": "meta"
        }
      }
    },
    {
      "id": "message_1",
      "type": "message",
      "position": { "x": 700, "y": 100 },
      "data": {
        "label": "Resultado",
        "parameters": {
          "message": "Imagens encontradas: {{meta.images}}"
        }
      }
    },
    {
      "id": "end_1",
      "type": "end",
      "position": { "x": 900, "y": 100 },
      "data": { "label": "Fim" }
    }
  ],
  "edges": [
    { "source": "start_1", "target": "variable_1" },
    { "source": "variable_1", "target": "parser_1" },
    { "source": "parser_1", "target": "message_1" },
    { "source": "message_1", "target": "end_1" }
  ]
}

Teste: Esperado: Array ["foto1.jpg", "foto2.jpg"]

metadataVariable (string, opcional)

O que é: Variável para armazenar metadados (links, imagens, tamanhos, estrutura).

Padrão: Não define

Flow completo para testar:

{
  "name": "Teste HTML Parser - Metadata Structured",
  "nodes": [
    {
      "id": "start_1",
      "type": "start",
      "position": { "x": 100, "y": 100 },
      "data": { "label": "Início" }
    },
    {
      "id": "variable_1",
      "type": "variable",
      "position": { "x": 300, "y": 100 },
      "data": {
        "label": "Documento",
        "parameters": {
          "variableName": "doc",
          "variableValue": "<html><body><h1>Doc</h1><p>Conteúdo do documento aqui.</p></body></html>"
        }
      }
    },
    {
      "id": "parser_1",
      "type": "html_parser",
      "position": { "x": 500, "y": 100 },
      "data": {
        "label": "Parse",
        "parameters": {
          "inputVariable": "doc",
          "parseMode": "structured",
          "outputVariable": "estrut",
          "metadataVariable": "info"
        }
      }
    },
    {
      "id": "message_1",
      "type": "message",
      "position": { "x": 700, "y": 100 },
      "data": {
        "label": "Ver Info",
        "parameters": {
          "message": "Estrutura: {{estrut}}\n\nMetadados: {{info}}"
        }
      }
    },
    {
      "id": "end_1",
      "type": "end",
      "position": { "x": 900, "y": 100 },
      "data": { "label": "Fim" }
    }
  ],
  "edges": [
    { "source": "start_1", "target": "variable_1" },
    { "source": "variable_1", "target": "parser_1" },
    { "source": "parser_1", "target": "message_1" },
    { "source": "message_1", "target": "end_1" }
  ]
}

Teste: Esperado: Estrutura JSON + metadados com tamanhos e structure

Parâmetros

Campo Tipo Obrigatório Descrição
inputVariable string Sim Variável contendo HTML a processar
parseMode string Sim Modo (use "structured")
outputVariable string Não Variável para resultado JSON (padrão: "parsed_content")
removeScripts boolean Não Remove scripts (padrão: true)
removeStyles boolean Não Remove styles (padrão: true)
extractLinks boolean Não Extrai links (padrão: false)
extractImages boolean Não Extrai imagens (padrão: false)
metadataVariable string Não Variável para metadados

Exemplo 1: Extrair Índice de Documentação

Objetivo: Extrair todos os headings de uma página de docs para criar índice navegável

JSON para Importar

{
  "name": "Extração de Índice de Documentação",
  "nodes": [
    {
      "id": "start_1",
      "type": "start",
      "position": { "x": 100, "y": 100 },
      "data": { "label": "Início" }
    },
    {
      "id": "variable_1",
      "type": "variable",
      "position": { "x": 300, "y": 100 },
      "data": {
        "label": "HTML Docs",
        "parameters": {
          "variableName": "docs_html",
          "variableValue": "<html><body><h1 id='intro'>Introdução</h1><p>Texto introdutório com mais de vinte caracteres de conteúdo.</p><h2 id='install'>Instalação</h2><p>Como instalar o sistema passo a passo detalhadamente.</p><h3 id='requisitos'>Requisitos</h3><p>Lista de requisitos necessários para instalação completa.</p><h2 id='uso'>Uso</h2><p>Instruções de uso do sistema após instalação completa.</p></body></html>"
        }
      }
    },
    {
      "id": "parser_1",
      "type": "html_parser",
      "position": { "x": 500, "y": 100 },
      "data": {
        "label": "Extrair Estrutura",
        "parameters": {
          "inputVariable": "docs_html",
          "parseMode": "structured",
          "outputVariable": "estrutura_docs"
        }
      }
    },
    {
      "id": "message_1",
      "type": "message",
      "position": { "x": 700, "y": 100 },
      "data": {
        "label": "Criar Índice",
        "parameters": {
          "message": "📑 Índice da Documentação:\n\n{{estrutura_docs.headings}}\n\n📊 Total de parágrafos: {{estrutura_docs.paragraphs.length}}"
        }
      }
    },
    {
      "id": "end_1",
      "type": "end",
      "position": { "x": 900, "y": 100 },
      "data": { "label": "Fim" }
    }
  ],
  "edges": [
    { "source": "start_1", "target": "variable_1" },
    { "source": "variable_1", "target": "parser_1" },
    { "source": "parser_1", "target": "message_1" },
    { "source": "message_1", "target": "end_1" }
  ]
}

Saída esperada:

Sistema: 📑 Índice da Documentação:

[
  {"level": 1, "text": "Introdução", "id": "intro"},
  {"level": 2, "text": "Instalação", "id": "install"},
  {"level": 3, "text": "Requisitos", "id": "requisitos"},
  {"level": 2, "text": "Uso", "id": "uso"}
]

📊 Total de parágrafos: 4

Exemplo 2: Processar Tabela de Dados

Objetivo: Extrair dados de tabela HTML para processamento posterior

JSON para Importar

{
  "name": "Extração de Tabela HTML",
  "nodes": [
    {
      "id": "start_1",
      "type": "start",
      "position": { "x": 100, "y": 100 },
      "data": { "label": "Início" }
    },
    {
      "id": "variable_1",
      "type": "variable",
      "position": { "x": 300, "y": 100 },
      "data": {
        "label": "Relatório HTML",
        "parameters": {
          "variableName": "relatorio_html",
          "variableValue": "<html><body><h1>Relatório de Vendas</h1><table><thead><tr><th>Produto</th><th>Quantidade</th><th>Valor</th></tr></thead><tbody><tr><td>Produto A</td><td>10</td><td>R$ 1.000</td></tr><tr><td>Produto B</td><td>5</td><td>R$ 500</td></tr><tr><td>Produto C</td><td>15</td><td>R$ 1.500</td></tr></tbody></table></body></html>"
        }
      }
    },
    {
      "id": "parser_1",
      "type": "html_parser",
      "position": { "x": 500, "y": 100 },
      "data": {
        "label": "Extrair Tabelas",
        "parameters": {
          "inputVariable": "relatorio_html",
          "parseMode": "structured",
          "outputVariable": "dados_estruturados"
        }
      }
    },
    {
      "id": "loop_1",
      "type": "loop",
      "position": { "x": 700, "y": 100 },
      "data": {
        "label": "Processar Linhas",
        "parameters": {
          "items": "{{dados_estruturados.tables[0].rows}}",
          "itemVariable": "linha"
        }
      }
    },
    {
      "id": "message_1",
      "type": "message",
      "position": { "x": 900, "y": 100 },
      "data": {
        "label": "Processar Linha",
        "parameters": {
          "message": "Produto: {{linha[0]}} | Qtd: {{linha[1]}} | Valor: {{linha[2]}}"
        }
      }
    },
    {
      "id": "end_1",
      "type": "end",
      "position": { "x": 1100, "y": 100 },
      "data": { "label": "Fim" }
    }
  ],
  "edges": [
    { "source": "start_1", "target": "variable_1" },
    { "source": "variable_1", "target": "parser_1" },
    { "source": "parser_1", "target": "loop_1" },
    { "source": "loop_1", "target": "message_1" },
    { "source": "message_1", "target": "end_1" }
  ]
}

Saída esperada:

Sistema: Produto: Produto A | Qtd: 10 | Valor: R$ 1.000
Sistema: Produto: Produto B | Qtd: 5 | Valor: R$ 500
Sistema: Produto: Produto C | Qtd: 15 | Valor: R$ 1.500

Exemplo 3: Análise de Estrutura de Artigo

Objetivo: Analisar a estrutura completa de um artigo (headings, parágrafos, listas)

JSON para Importar

{
  "name": "Análise Estrutural de Artigo",
  "nodes": [
    {
      "id": "start_1",
      "type": "start",
      "position": { "x": 100, "y": 100 },
      "data": { "label": "Início" }
    },
    {
      "id": "variable_1",
      "type": "variable",
      "position": { "x": 300, "y": 100 },
      "data": {
        "label": "Artigo HTML",
        "parameters": {
          "variableName": "artigo",
          "variableValue": "<article><h1>Guia Completo</h1><p>Este é um guia detalhado sobre o tema principal tratado.</p><h2>Tópicos Principais</h2><ul><li>Primeiro tópico importante</li><li>Segundo tópico relevante</li><li>Terceiro tópico essencial</li></ul><p>Cada tópico será explicado em detalhes nas próximas seções.</p><h2>Conclusão</h2><p>Resumo final das informações apresentadas ao longo do artigo.</p></article>"
        }
      }
    },
    {
      "id": "parser_1",
      "type": "html_parser",
      "position": { "x": 500, "y": 100 },
      "data": {
        "label": "Analisar Estrutura",
        "parameters": {
          "inputVariable": "artigo",
          "parseMode": "structured",
          "extractLinks": true,
          "extractImages": true,
          "outputVariable": "estrutura",
          "metadataVariable": "analise"
        }
      }
    },
    {
      "id": "calculator_1",
      "type": "calculator",
      "position": { "x": 700, "y": 100 },
      "data": {
        "label": "Calcular Métricas",
        "parameters": {
          "expression": "{{estrutura.headings.length}} + {{estrutura.paragraphs.length}} + {{estrutura.lists.length}}",
          "outputVariable": "total_elementos"
        }
      }
    },
    {
      "id": "message_1",
      "type": "message",
      "position": { "x": 900, "y": 100 },
      "data": {
        "label": "Relatório",
        "parameters": {
          "message": "📊 Análise Estrutural\n\nTítulos: {{estrutura.headings.length}}\nParágrafos: {{estrutura.paragraphs.length}}\nListas: {{estrutura.lists.length}}\nTotal: {{total_elementos}} elementos\n\nTítulo: {{estrutura.title}}"
        }
      }
    },
    {
      "id": "end_1",
      "type": "end",
      "position": { "x": 1100, "y": 100 },
      "data": { "label": "Fim" }
    }
  ],
  "edges": [
    { "source": "start_1", "target": "variable_1" },
    { "source": "variable_1", "target": "parser_1" },
    { "source": "parser_1", "target": "calculator_1" },
    { "source": "calculator_1", "target": "message_1" },
    { "source": "message_1", "target": "end_1" }
  ]
}

Saída esperada:

Sistema: 📊 Análise Estrutural

Títulos: 3
Parágrafos: 3
Listas: 1
Total: 7 elementos

Título: Guia Completo

Resposta do Node

{
  "success": true,
  "data": {
    "parsed_content": "{\"title\":\"Título\",\"headings\":[...],\"paragraphs\":[...],\"lists\":[...],\"tables\":[...]}",
    "metadata": {
      "structure": {
        "title": "Título do Documento",
        "headings": [],
        "paragraphs": [],
        "lists": [],
        "tables": []
      },
      "originalLength": 450,
      "parsedLength": 380
    },
    "stats": {
      "originalLength": 450,
      "parsedLength": 380,
      "mode": "structured",
      "hasLinks": 0,
      "hasImages": 0
    }
  },
  "executionTime": 58,
  "logs": [
    "Parsed HTML in structured mode",
    "Original: 450 chars → Parsed: 380 chars"
  ]
}

Boas Práticas

SIM:

  • Use para extrair índices e estruturas de documentação
  • Use para processar tabelas HTML em dados estruturados
  • Combine com LOOP para iterar sobre headings, listas ou rows de tabelas
  • Use extractLinks/extractImages quando precisar processar recursos referenciados
  • Filtre parágrafos por tamanho usando a propriedade paragraphs.length

NÃO:

  • Não use se precisar apenas texto simples (use parse_text)
  • Não use se precisar formato Markdown (use parse_markdown)
  • Não confie em extração de parágrafos < 20 caracteres (são filtrados automaticamente)
  • Não use para extrair elementos específicos por classe/id (use parse_custom)

Dicas

💡 Dica 1: O output é JSON stringified - use JSON.parse() se precisar manipular programaticamente

💡 Dica 2: Headings incluem propriedade id se o elemento HTML tiver atributo id (útil para âncoras)

💡 Dica 3: Apenas parágrafos com mais de 20 caracteres são incluídos (filtra texto insignificante)

💡 Dica 4: Listas retornam apenas itens diretos (> li) - listas aninhadas não são capturadas

💡 Dica 5: Tabelas extraem headers do <thead> e rows do <tbody> - estruture HTML corretamente

Próximo Node

PARSE_TEXT - Extrai texto puro sem estrutura → PARSE_MARKDOWN - Converte HTML para Markdown → PARSE_CUSTOM - Extrai elementos específicos com seletores CSS