Python configures free OCR image recognition text (with code)

Today, I swiped a post to a website, which can be recognized by OCR for free, but I didn’t calculate the specific number of times, and there is no specific description in the document, so let’s take a look together.

First of all, the URL is here: click me directly

1. We need to register an account to obtain very important parameters【ColaKey

insert image description here
insert image description here

2. Next, let's take a look at the document description (skipable), click me to go directly

insert image description here

3. Instructions for use

1、URL,POST请求:https://luckycola.com.cn/aiTools/imgOcr

2. Parameters: Important reminder ⚠️: The interface request parameters are in multipart/form-data format ⚠️

serial number parameter Is it necessary illustrate
1 ColaKey yes The unique verification ColaKey can be obtained from the official website (http(s): //luckycola.com.cn (opens new window))
2 file yes The image resource (png, jpg, jpeg format) that needs to be identified, note: the interface request parameter is in multipart/form-data format
3 lang no Whether the content of the currently detected picture is Chinese or English, if it is Chinese, the parameter value can not be passed, if it is English, pass in "eng", be sure to set the value correctly

3. I used Postman to test, the following is my original image and recognition effect

insert image description here
insert image description here

ok The recognition is successful, but the accuracy is not very accurate

4. Code, you can directly use Postman to generate code! !

insert image description here

import requests

url = "https://luckycola.com.cn/aiTools/imgOcr"

payload = {
    
    'ColaKey': '写上自己的'}
files=[
  ('file',('img.png',open(r'd:/user/桌面/img.png','rb'),'image/png'))
]
headers = {
    
    
  'Cookie': '会自动生成'
}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

print(response.text)

insert image description here

Well, that’s all for today’s sharing, I’ve written a few articles before, interested friends, you can go to the archeology:

Python+Tesseract realizes its own OCR unlimited recognition (nanny level)

Python configures free OCR recognition (OCRSpace) 25,000 times per month (nanny level teaching)

Python calls Baidu picture recognition text to have a recognition tool

insert image description here

I hope everyone has to help

A little programmer dedicated to office automation

I've seen this, follow + like + bookmark = don't get lost! !

Guess you like

Origin blog.csdn.net/weixin_42636075/article/details/132619855