赞
踩
爬虫时,你是否碰到过这种验证码比较的头疼
依赖库的安装
pip install ddddocr
带带弟弟 OCR 可以识别三种验证码,小编就用这三种来实验一下。
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)
识别结果:
{'target_y': 0, 'target': [486, 126, 622, 262]}
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)
ocr = ddddocr.DdddOcr(old=True)
with open("z1.jpg", 'rb') as f:
image = f.read()
res = ocr.classification(image)
print(res)
# 识别结果
3n3d
8342
ddddocr 让验证码变得如此简单与易用,,让不会用 opencv, pytorch, tensorflow 的小伙伴也能快速的破解网站的登录验证码。小伙伴们如果有其他好的 ocr 识别也可以在留言中分享出来。
不要干坏事哦
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。