-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
40 lines (37 loc) · 1.22 KB
/
server.py
File metadata and controls
40 lines (37 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from requests import get
def getData(data, separador):
data = data.split(separador)[1]
cont = 0
for c in data:
if c == '"':
return data[0:cont]
else:
cont += 1
def hello(cpf):
if len(cpf) != 11 or cpf.isdigit() == False:
return {
"status":900,
"noticia":"CPF INVALIDO"
}
data = get(f"#").text
if '<ROOT/>' in data:
return {
"status":400,
"noticia":"CPF INVALIDO ou NAO FOI ENCONTRADO"
}
allData = {
"status":200,
"noticia":"Seu CPF foi consultado",
"cpfConsultado":getData(data, 'NRCPF="'),
"nomeCompleto":getData(data, 'NOPESSOAFISICA="'),
"dataNascimento":getData(data, 'DTNASCIMENTO="'),
"nomeDaMae":getData(data, 'NOMAE="'),
"nomeLogradouro":getData(data, 'NOLOGRADOURO="'),
"numeroLogradouro":getData(data, 'NRLOGRADOURO="'),
"dsComplemento":getData(data, 'DSCOMPLEMENTO="'),
"nomeBairro":getData(data, 'NOBAIRRO="'),
"nomeMunicipio":getData(data, 'NOMUNICIPIO="'),
"SiglaEstadoBrasileiro":getData(data, 'SGUF="'),
"cep":getData(data, 'NRCEP="')}
print(allData)
return allData