代码拉取完成,页面将自动刷新
import requests
import base64
import json
from datetime import datetime
smart_server = 'http://118.24.37.241:18080/smart'
# smart_server = 'http://localhost:18080/smart'
smart_token = "54DD84sg0sa18m6jq8u6bmbqYUdfu8dsx"
def get_file_content(filePath):
with open(filePath, 'rb') as fp:
encoded_string = base64.b64encode(fp.read())
return encoded_string.decode("utf-8")
def recognize(file_path):
url = "https://eolink.o.apispace.com/ocrbase/ocr/v1/base"
image = get_file_content(filePath=file_path)
payload = {"image":image,"url":"","pdf":"","language":"CHN_ENG"}
headers = {
"X-APISpace-Token":"5zjtsg0sa18m6tceas6ljq8u6b5vmmbq",
"Content-Type":"application/json"
}
response=requests.request("POST", url, data=json.dumps(payload), headers=headers)
print(response.text)
return response.text
def match_price(payload):
url = smart_server + "/reply/match/price/byOcr"
headers = {
"token": smart_token,
"Content-Type":"application/json"
}
response=requests.request("POST", url, data=json.dumps(payload), headers=headers)
print(response.text)
res = json.loads(response.text)
if (res['code'] == 200 and res['data'] is not None):
return res['data']
return "正在查询,请稍候..."
def get_hardware(name):
url = smart_server + "/system/hardware?name=" + name
headers = {
"token": smart_token,
"Content-Type":"application/json"
}
response = requests.get(url=url,headers=headers)
res = json.loads(response.text)
print(res)
if (res['code'] == 200):
return res['data']
print("查询硬件信息失败,请联系管理员!!!!!" + res['message'])
return None
if __name__ == "__main__":
print(datetime.now().strftime('%Y-%m-%d-%H:%M:%S.s '),888,"测试文字")
ocrResponse = recognize(r"C:\Users\lixf\Desktop\temp\0.jpg")
priceRequest = {
'hardwareName': 'windows_L14_1920*1080_percent100',
'wangwangName': 'test',
'ocrResponse': ocrResponse
}
priceResult = match_price(priceRequest)
print(priceResult)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。