Spaces:
Sleeping
Sleeping
File size: 624 Bytes
19a3093 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | import httpx
base_url = 'https://lex.lab.i.ai.gov.uk'
url = f'{base_url}/legislation/section/search'
payload = {
'query': 'patient wants to leave but is sectioned',
'limit': 5
}
r = httpx.post(url, json=payload, timeout=10)
print('Status:', r.status_code)
d = r.json()
if isinstance(d, list) and d:
for n in d:
print('---')
act_name = n.get('act_name', 'Unknown')
sec_num = n.get('number', '??')
sec_title = n.get('title', 'No Title')
print(f'{act_name} - Section {sec_num}: {sec_title}')
print(f'Text: {n.get("text", "")[:100]}...')
else:
print('Raw:', d)
|