123456789101112131415161718192021222324252627282930313233343536373839 |
- import base64
- import requests
- # 测试url
- test_url = 'http://aihub-test.digitalyili.com/aiSquare/openApi/reasoning-services/rlocrxm'
- sb_url = 'http://aihub.digitalyili.com/aiSquare/openApi/reasoning-services/rlocrxm'
- idc_url = 'http://aihubpre-idc.digitalyili.com/aiSquare/openApi/reasoning-services/hrocr'
- URL = {
- 'test': test_url,
- 'sb': sb_url,
- 'idc': idc_url
- }
- # 测试token
- test_header = {
- 'Content-Type': 'application/json',
- 'Authorization': 'Bearer 9679c2b3-b90b-4029-a3c7-f347b4d242f7'
- }
- sb_header = {
- 'Content-Type': 'application/json',
- 'Authorization': 'Bearer dcae8cc6-0e49-4db8-a2d2-94ef84da3636'
- }
- idc_header = {
- 'Content-Type': 'application/json',
- 'Authorization': 'Bearer 4e00c444-620b-4d3c-85f4-777e64276f0e'
- }
- TOKEN = {
- 'test': test_header,
- 'sb': sb_header,
- 'idc': idc_header
- }
- def send_request(image_path, suffix, URL, TOKEN):
- with open(image_path, 'rb') as f:
- img_str: str = base64.encodebytes(f.read()).decode('utf-8')
- r = requests.post(f'{URL}{suffix}', json={'image': img_str, 'image_type': '0'}, headers=TOKEN)
- return r.json()
|