当前位置:网站首页>With a younger brother OCR, say no to various types of verification codes!

With a younger brother OCR, say no to various types of verification codes!

2022-06-25 06:24:00 Python Technology

885c8943e8aa0629de6fcb23412fa4cf.png

writing |  So and so white rice

source :Python technology 「ID: pythonall」

370f30f22c8983ad1f25c7685c6bf71f.png

When using a crawler to log in to a website , You often encounter verification code after entering user name and password , A simpler code with letters , A little more complicated is the slider verification code , Click the article and click the picture verification code . These are all chronic problems in reptiles , Today, we will introduce a universal verification code SDK Say goodbye to them completely , Its name is ddddocr Take your brother OCR Universal verification code identification SDK Free open source .
f6e4c80f4722084e5ebec256e208fab3.png

install

Will automatically install the latest software that conforms to your computer environment ddddocr.Python Environment needs to be less than or equal to 3.9.

pip install ddddocr

Use

Take your brother OCR Three verification codes can be identified , Xiaobian will experiment with these three methods .

Slider verification code

Slider verification code here is the slider verification of Douban . The lower slider is a separate transparent background hycdn.png.

86fdcc1d1dbec90353ac50ef88737764.png
hycdn.png

The background image is a pit with a small slider background.jpg.

77134d0e551a7ed48b3c587c3968bf49.png
background
import ddddocr

det = ddddocr.DdddOcr(det=False, ocr=False)

with open('hycdn.png', 'rb') as f:
        target_bytes = f.read()
    
with open('background.jpg', 'rb') as f:
    background_bytes = f.read()

res = det.slide_match(target_bytes, background_bytes, simple_target=True)

print(res)

Recognition result

{'target_y': 0, 'target': [486, 126, 622, 262]}

target The first two values of the attribute coincide with the Douban validation slider url Submitted in ans almost .

36dec3b04eb341c27f6e3e465acabb62.png

Click the class verification code

Click the type verification code to use Netease login

7c9ca99f75fbc88acbbb7511e1764498.png
eb.jpg
det = ddddocr.DdddOcr(det=True)

    with open("eb.jpg", 'rb') as f:
        image = f.read()

    poses = det.detection(image)

    im = cv2.imread("eb.jpg")

    for box in poses:
        x1, y1, x2, y2 = box
        im = cv2.rectangle(im, (x1, y1), (x2, y2), color=(0, 0, 255), thickness=2)

    cv2.imwrite("result.jpg", im)

Recognition result

388254d0d8c2395f9c6f600ba95924c1.png

Alphanumeric verification code

The picture of alphanumeric verification code comes from google Search for

d32de951817d62bfac689d0ea43000c9.png
ocr = ddddocr.DdddOcr(old=True)

with open("z1.jpg", 'rb') as f:
    image = f.read()

res = ocr.classification(image)
print(res)

Recognition result

3n3d
8342

summary

ddddocr Make the verification code so simple and easy to use ,, It won't work opencv, pytorch, tensorflow Our little partner can also quickly crack the login verification code of the website . If you have other good friends ocr Recognition can also be shared in messages .

PS: Reply within company number 「Python」 You can enter Python Novice learning communication group , Together 100 Day plan !

Old rules , Brothers, remember , Right lower corner “ Looking at ” click , If you think the content of the article is good , Remember to share the circle of friends and let more people know !

b2f94ed16a2003a9b5152b170702db6e.gif

Code Access method

Identify the QR code at the end of the text , reply : So and so white rice

62b054b48a44916607158a3227c0f343.png

原网站

版权声明
本文为[Python Technology]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202201234162802.html