百度api mac地址提取
# encoding:utf-8
import requests
import base64
import pprint
import re
def get_token():
host = ‘https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&‘ ‘client_id=client_secret=‘
response = requests.get(host)
if response:
return response.json()
def all_text():
"""
通用文字识别
:return:
"""
request_url = "https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic"
# 二进制方式打开图片文件
with open(‘mac.jpg‘, ‘rb‘) as f:
img = base64.b64encode(f.read())
params = {"image": img}
access_token = ‘‘
request_url = request_url + "?access_token=" + access_token
headers = {‘content-type‘: ‘application/x-www-form-urlencoded‘}
response = requests.post(request_url, data=params, headers=headers)
if response:
return response.json()
if __name__ == ‘__main__‘:
# pprint.pprint(get_token())
a = all_text()
b = str(a[‘words_result‘])
print(b)
print(re.search(r‘([A-Fa-f0-9]{2}-){5}[A-Fa-f0-9]{2}‘, b)) 相关推荐
86193952 2020-10-27
Mynamezhuang 2020-09-18
充满诗意的联盟 2020-08-23
raksmart0 2020-08-17
yfightfors 2020-08-16
84487600 2020-08-16
qdqht00 2020-07-26
WebVincent 2020-07-21
hzyuhz 2020-07-04
fengchao000 2020-07-04
javaraylu 2020-06-28
baijinswpu 2020-06-28
ZHANGRENXIANG00 2020-06-28
Teamomc 2020-06-28
Catastrophe 2020-06-26
hell0kitty 2020-06-17
我欲疾风前行 2020-06-18
标题无所谓 2020-06-14