Skip to content

Instantly share code, notes, and snippets.

@illmoded
Created September 20, 2019 12:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save illmoded/f4ac29bb4e777db6e52fee091c2ee56c to your computer and use it in GitHub Desktop.
Save illmoded/f4ac29bb4e777db6e52fee091c2ee56c to your computer and use it in GitHub Desktop.
Ten gist pokazuje jak ściągać dane z CEIDG z pomocą pythona i zeep.
import datetime
import json
import zeep
from lxml import etree, objectify
from lxml_to_dict import lxml_to_dict
def get_id(date_from, date_to):
r = client.service.GetID(AuthToken=key, DateFrom=date_from, DateTo=date_to)
root = etree.fromstring(r)
return root
def get_data(id_list):
array_of_string = client.get_element('ns2:ArrayOfstring')
list_of_ids = array_of_string(id_list)
request_data = {'AuthToken': key, 'UniqueId': list_of_ids}
r = client.service.GetMigrationData201901(**request_data)
return r
if __name__ == "__main__":
"""
API docs
https://datastore.ceidg.gov.pl/CEIDG.DataStore/Styles/Regulations/API_Datastore_20190314.pdf
"""
ceidg_address = 'https://datastoretest.ceidg.gov.pl/CEIDG.DataStore/services/DataStoreProvider201901.svc?wsdl'
key = ''
client = zeep.Client(ceidg_address)
date_1 = datetime.date(2018, 1, 1)
date_2 = datetime.date(2018, 9, 1)
a = get_id(date_1, date_2)
ids = [e.text for e in a]
b = get_data(ids)
o = objectify.fromstring(b)
d = lxml_to_dict(o)
print(json.dumps(d, indent=4, sort_keys=True))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment