Baidu authentication Code Recognition API use

Source: Internet
Author: User

First to Baidu Cloud application text recognition API, will give you an API key and a secret key, free, up to 500 times a day request.


Try
Temp_url = ' https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id= ' API KEY & Client_secret= "Secret KEY" '
Temp_res = Requests.post (Temp_url)
Temp_token = eval (temp_res.text) [' Access_token ']
Temp_url = ' https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic?access_token= ' + temp_token
Temp_headers = {' Content-type ': ' application/x-www-form-urlencoded '}
Temp_file = open (' code_xjtu.png ', ' RB ')
Temp_image = Temp_file.read ()
Temp_file.close ()
Temp_data = {
' Image ': Base64.b64encode (temp_image)
}
Temp_data = Urllib.parse.urlencode (temp_data)
Temp_res = Requests.post (Url=temp_url, Data=temp_data, Headers=temp_headers)
Code = Int (eval (temp_res.text) [' Words_result '][0][' words '])
Except Exception as E:
Print (e)
Print (' Verification Code identification exception, please contact Administrator ')

Baidu authentication Code Recognition API use

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.