Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jur - Brazilian Courts Jurisprudence Crawler

CLI tool for searching jurisprudence (case law) across multiple Brazilian courts, built with Playwright.

Supported Courts

Command Court Scope Status
trf1 Tribunal Regional Federal da 1ª Região DF, MG, GO, TO, MT, BA, PI, MA, PA, AP, AM, RR, AC, RO OK
trf2 Tribunal Regional Federal da 2ª Região RJ, ES OK
trf3 Tribunal Regional Federal da 3ª Região SP, MS ⚠️ Restrição de navegador — instável
trf4 Tribunal Regional Federal da 4ª Região RS, SC, PR OK
trf5 Tribunal Regional Federal da 5ª Região AL, CE, PB, PE, RN, SE OK
tcu Tribunal de Contas da União Federal (acórdãos) OK
tjpr Tribunal de Justiça do Paraná PR OK
tjsp Tribunal de Justiça de São Paulo SP 🚫 Sem acesso — não usar

TRF3: o site aplica verificação de navegador que falha intermitentemente em modo headless. Tente -v / --headed ou o fallback Python em src/trf3_drission.py. Para matéria previdenciária federal com origem em SP, considere também TRF4/TRF5 pra material comparável.

TJSP: sem acesso disponível hoje — não rodar em pipelines.

Installation

npm install
npx playwright install chromium

Quick Start

./bin/jur trf4 -q "Direito Previdenciario" -di "01/01/2024" -df "31/12/2024"

CLI Reference

All commands share a common base plus tribunal-specific options. Run ./bin/jur <command> --help for full flag list.

Common flags (todos os tribunais)

Flag Long Description
-q --query Search query (required)
-m --max-pages Max pages to crawl (default: 10)
-o --output Output JSON file
-v --visible Show browser window
--headed Alias for --visible
--json Quiet mode: suppress logs, JSON summary only

TRF4 (trf4)

-di, --data-inicio <date>       Decision start date (DD/MM/YYYY)
-df, --data-fim <date>          Decision end date (DD/MM/YYYY)
-dpi, --data-pub-inicio <date>  Publication start date (DD/MM/YYYY)
-dpf, --data-pub-fim <date>     Publication end date (DD/MM/YYYY)
--origem <tipo>                 trf4 (default) | turmas-recursais
--fetch-inteiro-teor            Download full text of each result
--output-dir <dir>              Directory for downloaded files (default: ./resultados)
--max-results <number>          Max total results to collect

TRF1 (trf1)

-di, --data-inicio <date>  Start date (DD/MM/YYYY)
-df, --data-fim <date>     End date (DD/MM/YYYY)
-td, --tipo-data <type>    DTDP (Julgamento) | DTPP (Publicacao), default DTDP
-r,  --relator <name>      Relator name
-oj, --orgao-julgador      Judging body (ex: "PRIMEIRA TURMA")
-c,  --classe              Case class
-n,  --numero              Case number
-t,  --tipos               ACORDAO,SUMULA,ARGUICAO,DECISAOMONO (default: ACORDAO)
-f,  --fontes              TRF1,JEF1 (default: TRF1)

TRF2 (trf2)

-di, --data-inicio <date>  Judgment start date (DD/MM/YYYY)
-df, --data-fim <date>     Judgment end date (DD/MM/YYYY)
-r,  --relator
-oj, --orgao               Orgao Colegiado (ex: "1a. TURMA ESPECIALIZADA")
-c,  --classe              Ex: "Apelacao Civel"
-cp, --competencia
-n,  --numero
-ord,--ordenacao           RELEV (default) | DESC | ASC
--trf                      Only TRF da 2a Regiao
--tru                      Only TRU e Turmas Recursais
--ementa                   Search only in ementa

TRF3 (trf3) ⚠️

Restrição de navegador. Prefira -v / --headed; em caso de falhas recorrentes, use o fallback Python em src/trf3_drission.py.

-di,  --data-inicio <date>   Start date (DD/MM/YYYY)
-df,  --data-fim <date>      End date (DD/MM/YYYY)
-td,  --tipo-data            Publicação (default) | Julgamento
-r,   --relator
-oj,  --orgao                Ex: "9ª Turma"
-c,   --classe               Ex: "ApCiv - APELAÇÃO CÍVEL"
-n,   --numero
-e,   --ementa <text>        Text to search in ementa
-b,   --base                 0=TRF3 (default) | 1=Turmas Recursais | 2=Monocráticas
-rpp, --results-per-page     10 (default) | 30 | 50

TRF5 (trf5)

-di, --data-inicio <date>  Start date (DD/MM/YYYY)
-df, --data-fim <date>     End date (DD/MM/YYYY)
-r,  --relator
-oj, --orgao               Ex: "1ª TURMA", "PLENO"
-n,  --numero
-t,  --tipo                segundoGrau (default) | turmaRecursal | tru
-e,  --estados             For turmaRecursal: AL,CE,PB,PE,RN,SE

TCU (tcu)

Acórdãos do TCU. Query suporta operadores: E, OU, ADJ, NAO, PROX, MESMO, $.

-di, --data-inicio <date>  Session start date (DD/MM/YYYY)
-df, --data-fim <date>     Session end date (DD/MM/YYYY)

TJPR (tjpr)

Query suporta operadores: E, OU, !NAO, PROX, $.

-di, --data-inicio <date>  Judgment start date (DD/MM/YYYY)
-df, --data-fim <date>     Judgment end date (DD/MM/YYYY)
-l,  --local <scope>       1=EMENTA | 2=INTEIRO TEOR (default) | 99=AMBAS

TJSP (tjsp) 🚫

Sem acesso disponível. Subcomando existe no binário mas não deve ser executado em pipelines. Documentado apenas para referência.

Query suporta operadores: E, OU, NAO, "".

-di,  --data-inicio <date>      Judgment start date (DD/MM/YYYY)
-df,  --data-fim <date>         Judgment end date (DD/MM/YYYY)
-dpi, --data-pub-inicio <date>  Publication start date (DD/MM/YYYY)
-dpf, --data-pub-fim <date>     Publication end date (DD/MM/YYYY)
--2grau / --no-2grau            Include/exclude 2° grau (default: include)
--recursal / --no-recursal      Include/exclude Colégios Recursais (default: include)
--acordaos / --no-acordaos      Include/exclude Acórdãos (default: include)
--homologacoes                  Include Homologações de Acordo
--decisoes-mono                 Include Decisões Monocráticas

Examples

Busca simples em TRF4

./bin/jur trf4 -q "Direito Previdenciario"

Aposentadoria especial com filtro de data (TRF3 / SP-MS)

./bin/jur trf3 -q "aposentadoria especial" -di "01/01/2026" -df "31/03/2026" --json -o /tmp/trf3-especial.json

Tempo especial em múltiplos tribunais (rodar em paralelo)

./bin/jur trf4 -q "tempo especial" -di "01/01/2026" -df "31/03/2026" --json -o /tmp/trf4.json &
./bin/jur trf1 -q "tempo especial" -di "01/01/2026" -df "31/03/2026" --json -o /tmp/trf1.json &
./bin/jur trf2 -q "tempo especial" -di "01/01/2026" -df "31/03/2026" --json -o /tmp/trf2.json &
./bin/jur trf5 -q "tempo especial" -di "01/01/2026" -df "31/03/2026" --json -o /tmp/trf5.json &
wait

Acórdãos do TCU sobre RPPS

./bin/jur tcu -q "aposentadoria E RPPS" -di "01/01/2025" -df "31/12/2025"

Modo JSON para pipelines / agentes IA

./bin/jur trf4 -q "beneficio assistencial" --json

Retorna:

{"success":true,"count":42,"output":"/absolute/path/to/results.json"}

Download do inteiro teor (somente TRF4)

./bin/jur trf4 -q "aposentadoria especial enfermeiro" --fetch-inteiro-teor --output-dir ./resultados

Output Format

Results are saved as a JSON array. Fields vary por tribunal, mas os principais são:

Field Description
id Internal result ID
tipoDocumento Document type (Decisão monocrática, Acórdão, etc.)
processo Process number
processoUrl Link to full process details
orgaoJulgador Court chamber (e.g., 5ª Turma)
dataJulgamento Judgment date
dataPublicacao Publication date
relator Reporting judge
uf State (quando aplicável)
ementa Full decision/ementa text
inteiroTeorLink Link to download full document

Exit Codes

Code Meaning
0 Success
1 Execution error

Notes for AI Agents

  1. Sempre use aspas em termos compostos: -q "termo composto"
  2. Datas em formato brasileiro: DD/MM/YYYY
  3. Use --json para parsing programático
  4. Limite páginas com -m para buscas rápidas
  5. Chromium é obrigatório: npx playwright install chromium
  6. Timeout padrão: 60 segundos por operação
  7. ~20 resultados por página
  8. Não rodar TJSP (sem acesso) — e TRF3 é instável (restrição de navegador, use -v ou o fallback em trf3_drission.py)
  9. Para cobertura SP em matéria previdenciária federal, prefira TRF4/TRF5 como comparativo até o TRF3 ser resolvido
  10. Rode buscas em tribunais diferentes em paralelo (cada crawler sobe seu próprio browser)

Error Handling

Com --json, erros retornam:

{"success":false,"error":"error message"}

Erros comuns:

  • Timeout — verifique conexão ou reduza escopo com -m
  • No results — verifique termo de busca ou janela de data
  • Browser not found — rode npx playwright install chromium
  • TRF3: detecção de navegador — use -v e/ou retente; em último caso, rode src/trf3_drission.py (Python/DrissionPage)
  • TJSP: sem acesso — não tentar, fora de uso

Project Structure

bin/
  jur                 # CLI entry point (Commander) — todos os tribunais em um binário
src/
  BaseCrawler.js      # Abstract base class
  TRF1Crawler.js
  TRF2Crawler.js
  TRF3Crawler.js
  TRF4Crawler.js
  TRF5Crawler.js
  TCUCrawler.js
  TJPRCrawler.js
  TJSPCrawler.js      # ⚠️ instável
  trf3_drission.py    # Alternativa Python (DrissionPage) para TRF3
  inteiroTeorFetcher.js  # Download de PDFs (TRF4)
  index.js            # Backward-compat entry

Adding New Crawlers

Estenda BaseCrawler e implemente os métodos obrigatórios:

const BaseCrawler = require('./src/BaseCrawler');

class NewCourtCrawler extends BaseCrawler {
  constructor(options = {}) {
    super(options);
    this.baseUrl = 'https://court-website.jus.br/search';
  }

  async navigateToSearch() { /* ... */ }
  async configureFilters(filters) { /* ... */ }
  async executeSearch(query) { /* ... */ }
  async extractResults() { /* ... */ }
  async hasNextPage() { /* ... */ }
  async goToNextPage() { /* ... */ }
}

Depois registre o subcomando em bin/jur.

Programmatic Usage

const TRF4Crawler = require('./src/TRF4Crawler');

const crawler = new TRF4Crawler({ headless: true, timeout: 60000 });
const results = await crawler.search(
  'Direito Previdenciario',
  { dataDecisaoInicio: '01/01/2026', dataDecisaoFim: '31/03/2026' },
  { maxPages: 5 }
);
console.log(`Found ${results.length} results`);

License

ISC

About

CLI tool for searching jurisprudence (case law) across Brazilian courts: TRF1-5, TCU, TJPR, TJSP. Built with Playwright. Community-driven.

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages