-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.py
36 lines (28 loc) · 807 Bytes
/
api.py
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
import requests
import random
from settings import user_agents
def consultaDivida(cpf):
headers = {
'Accept': '*/*',
'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'pt',
'Connection': 'keep-alive',
'Authorization': 'Basic VVNFUl9DTElFTlRfQVBQOnBhc3N3b3Jk',
'User-Agent': random.choice(user_agents)
}
payload = {
'grant_type': 'password',
'username': 'credor-19',
'password': cpf,
'type': ''
}
with requests.post('https://negocie.scpc.com.br/oauth/token', data=payload, headers=headers) as r:
json_response = r.json()
headers.update(
{
'Authorization': 'Bearer {}'.format(json_response['access_token'])
}
)
with requests.get('https://negocie.scpc.com.br/consultardividas/19', headers=headers) as r:
json_response = r.json()
return json_response