organic: Enhance external apis

This commit is contained in:
2025-12-22 16:56:23 +01:00
parent 551ddd3c11
commit 0cd3b3de8e
10 changed files with 350 additions and 110 deletions

View File

@@ -33,8 +33,13 @@ def main() -> None:
query = {'PartnerCertSearchForm:pcs_' + q.split('=', 1)[0]: urllib.parse.unquote(q.split('=', 1)[-1]) for q in args.query.split('&')}
s = requests.Session()
r = s.get(f'{URL}?menu_sid=5002')
uri = ACTION_RE.findall(r.text)[0]
while True:
try:
r = s.get(f'{URL}?menu_sid=5002')
uri = ACTION_RE.findall(r.text)[0]
break
except IndexError:
pass
hidden = {m[1]: m[2] for m in HIDDEN_RE.finditer(r.text)}
r = s.post(f'{BASE_URL}{uri}', data={
@@ -69,7 +74,7 @@ def main() -> None:
'validTo': '-'.join(reversed(srow[2].split('-'))),
'type': srow[3],
'attachmentSid': srow[4],
'url': f'https://elwig.at/organic/external/bioqs/attachments/{urllib.parse.quote(srow[0])}',
'pdfUrl': f'https://elwig.at/organic/external/bioqs/attachments/{urllib.parse.quote(srow[0])}',
})
if not first:
print(',', flush=True)
@@ -80,10 +85,10 @@ def main() -> None:
'postalCode': row[3],
'city': row[4],
'address': row[5],
'autorityName': meta['Kontrollstelle'],
'authority': {'name': meta['Kontrollstelle']},
'productGroups': meta['Bereiche'],
'certificates': certificates,
}, ensure_ascii=False), end='')
}, ensure_ascii=False, separators=(',',':')), end='')
first = False
print('\n]')