Created
May 10, 2018 22:56
-
-
Save gilsonbp/5a4fe2a2267ccd23f438ca677470d631 to your computer and use it in GitHub Desktop.
Acessa o endpoint de fornecedores da API Comprasnet e imprime no console
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
import json | |
import requests | |
url = "http://compras.dados.gov.br/fornecedores/v1/fornecedores.json" | |
querystring = {"uf":"AL"} | |
response = requests.request("GET", url, params=querystring) | |
jsonresponse = json.loads(response.content) | |
for field in jsonresponse['_embedded']['fornecedores']: | |
if field.get('cnpj', None) is not None: | |
print(field['id'], field['cnpj'], field['nome'], field['uf']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment