1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- 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'
- blfe_url = 'http://aihubtest.digitalyili.com/aiSquare/openApi/reasoning-services/rlocrxm'
- URL = {
- 'test': test_url,
- 'sb': sb_url,
- 'idc': idc_url,
- 'blfe': blfe_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'
- }
- blfe_header = {
- 'Content-Type': 'application/json',
- 'Authorization': 'Bearer 8ae1e5f1-1337-4f22-8d46-ff4c110d68fd'
- }
- TOKEN = {
- 'test': test_header,
- 'sb': sb_header,
- 'idc': idc_header,
- 'blfe': blfe_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()
|