Created
March 8, 2017 16:01
-
-
Save luispimenta/dbcbf554338fdc73e957fea7bd153a87 to your computer and use it in GitHub Desktop.
Script simples para consulta de dados na base dados nacional do MEC utilizando o CPF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!usr/bin/env/ruby-w | |
require 'json' | |
require 'open-uri' | |
require 'optparse' | |
#Author: Mateus Lino a.k.a Dctor | |
#Site: https://mateuslino.com | |
options = {:hash => nil} | |
parser = OptionParser.new do|opts| | |
opts.banner = "Exemple: hashwitch.rb -m xxx.xxx.xxx.xx or --cplol xxx.xxx.xxx.xx " | |
opts.on('-m,', '--cplol', 'CPF ', String) do |hash| | |
options[:hash] = hash; | |
end | |
opts.on('-h', '--help', 'Help Commands') do | |
puts opts | |
exit | |
end | |
end | |
parser.parse! | |
cpf = options[:hash] | |
url = "http://sistec.mec.gov.br/precadastros/populacpf/cpf/#{cpf}" | |
payload = open(url).read | |
dados = JSON.parse(payload) | |
puts "API Dctor." | |
puts "Nome:" + dados["no_pessoa_rf"] | |
puts "CPF :" + dados["nu_cpf_rf"] | |
puts "Nome da Mãe:" + dados["no_mae_rf"] | |
puts "Data de Nascimento:" + dados["dt_nascimento_rf"] | |
puts "Sexo :" + dados["sg_sexo_rf"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sabe a nova url? @matheussicchieri