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

posted @ 2017-06-02 14:32  秋阳丶  阅读(175)  评论(0)    收藏  举报