Skip to content

Instantly share code, notes, and snippets.

@turicas
Created October 30, 2019 01:32
Show Gist options
  • Save turicas/c362fd387b4ab25e542532dfc6bc0472 to your computer and use it in GitHub Desktop.
Save turicas/c362fd387b4ab25e542532dfc6bc0472 to your computer and use it in GitHub Desktop.
Baixa sócios do Brasil.IO
import json
from urllib.request import urlopen
import rows
cnpjs = [
"00184878000124",
"01133144000189",
"01754020000110",
"01992743000158",
"02327119000107",
"02392295000114",
"02404361000129",
"02465103000152",
"02529379000157",
"51536795000198",
"08652284000102",
"10474704000150",
]
socios = []
for cnpj in cnpjs:
print(f"Baixando sócios de {cnpj}...")
url = "https://brasil.io/api/dataset/socios-brasil/socios/data?cnpj=" + cnpj
response = urlopen(url).read()
for socio in json.loads(response)["results"]:
socios.append(socio)
rows.export_to_csv(rows.import_from_dicts(socios), "socios.csv")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment