Skip to content

Instantly share code, notes, and snippets.

@jh00nbr
Last active May 17, 2023 17:36
Show Gist options
  • Star 30 You must be signed in to star a gist
  • Fork 16 You must be signed in to fork a gist
  • Save jh00nbr/9d713872f0e972d4fc9af4725a8a77aa to your computer and use it in GitHub Desktop.
Save jh00nbr/9d713872f0e972d4fc9af4725a8a77aa to your computer and use it in GitHub Desktop.
Script simples para consulta de dados na base dados nacional do SUS utilizando o CPF.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import requests,json,sys
# Script simples para consulta de dados na base dados nacional do SUS utilizando o CPF.
# Jhonathan Davi A.K.A jh00nbr / Insightl4b lab.insightsecurity.com.br
# jh00nbr: http://jhonathandavi.com.br
# Blog: lab.insightsecurity.com.br
# Github: github.com/jh00nbr
# Twitter @jh00nbr
try:
config = {'api_sus':'http://dabsistemas.saude.gov.br/sistemas/sadab/js/buscar_cpf_dbpessoa.json.php?cpf=', 'cpf':sys.argv[1]}
req = requests.get(config['api_sus']+config['cpf'])
dados = json.loads(req.content.decode("utf-8"))
# Retorna os dados no formato <nome_pessoa> / <numero_cpf> / <data_nascimento> / <nome_mae>"
print ("Nome: ", dados['NO_PESSOA_FISICA'], "\nCPF: ", dados['NU_CPF'], "\nData de nascimento:", dados['DT_NASCIMENTO'], "\nNome da mãe: ", dados['NO_MAE'])
# NU_CPF, NO_PESSOA_FISICA, DT_NASCIMENTO, CO_SEXO, NO_MAE, DS_SEXO
except IndexError:
print ("Entrada inválida! Adicione o CPF válido como argumento.\nEx.: ~$ python cpf_consulta_api_sus.py 00000000000")
@mendola0182
Copy link

+55 11 95472-7071

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment