码迷,mamicode.com
首页 > Windows程序 > 详细

百度api mac地址提取

时间:2020-08-19 19:51:09      阅读:98      评论:0      收藏:0      [点我收藏+]

标签:mac地址   打开   百度   requests   image   ati   turn   data   get   

# 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))

百度api mac地址提取

标签:mac地址   打开   百度   requests   image   ati   turn   data   get   

原文地址:https://www.cnblogs.com/oam-zhanjiang/p/13516925.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!