Basic search facility
This commit is contained in:
parent
14e656379c
commit
2f1df7fa90
19
namekrs.py
19
namekrs.py
@ -64,19 +64,26 @@ def verify(args, store):
|
||||
publish_parser = sub.add_parser('publish', help='publish mojepanstwo.pl data')
|
||||
publish_parser.add_argument('--limit', type=int, help='limit number of records', default=20)
|
||||
publish_parser.add_argument('--page', type=int, help='start with specified page', default=1)
|
||||
publish_parser.add_argument('--skip', type=int, help='skip first N records', default=0)
|
||||
publish_parser.add_argument('--search', help='search query (example: krs_podmioty.nip=1234567)')
|
||||
publish_parser.add_argument('-n', '--dry-run', action='store_true', help='only parse data')
|
||||
|
||||
@bind_parser(publish_parser)
|
||||
def publish(args, store):
|
||||
output = {}
|
||||
|
||||
data = requests.get('https://api-v3.mojepanstwo.pl/dane/krs_podmioty.json', {
|
||||
query = {
|
||||
'limit': args.limit,
|
||||
'page': args.page
|
||||
}).json()
|
||||
'page': args.page,
|
||||
}
|
||||
|
||||
if args.search:
|
||||
k, _, v = args.search.partition('=')
|
||||
query['conditions[%s]' % k] = v
|
||||
|
||||
data = requests.get('https://api-v3.mojepanstwo.pl/dane/krs_podmioty.json', query).json()
|
||||
logging.info('Total objects: %d, selected: %d', data['Count'], len(data['Dataobject']))
|
||||
|
||||
for obj in data['Dataobject']:
|
||||
output = {}
|
||||
for obj in data['Dataobject'][args.skip:]:
|
||||
if obj['data']['krs_podmioty.nip'] == '0':
|
||||
logging.info('Ignoring %s (no NIP/VATID)', obj['mp_url'])
|
||||
continue
|
||||
|
Loading…
x
Reference in New Issue
Block a user