Python读取简单图片验证码
# coding=utf-8
from pytesser import *
from PIL import ImageGrab
# 将验证码区域截图并保存
image_address='D:\\cc.png'
image_captcha = ImageGrab.grab((955,486,1035,513))
image_captcha.save(image_address,'png')
img = Image.open('D:\\cc.png')
img_grey = img.convert('L')
table = []
for i in range(256):
if i < 140:
table.append(0)
else:
table.append(1)
img_out = img_grey.point(table, '1')
text = image_to_string(img_grey)
print "image_captcha:", text

浙公网安备 33010602011771号