标签:rac top logs table 视频 灰度 imp tor open
# -*- coding: utf-8 -*- import urllib.request, urllib.parse from PIL import Image from pytesseract import * # ‘‘‘ # 获取验证码 # ‘‘‘ # auth_img_url = r‘http://www.myexception.cn/img/2014/10/22/13370857.jpg‘ # urllib.request.urlretrieve(auth_img_url, ‘auth.jpg‘) # # ‘‘‘ # 对图像进行灰度化,二值化处理 # ‘‘‘ img = Image.open(r"C:\Users\Administrator\Desktop\视频\1.gif") img_gray = img.convert(‘L‘) threshold = 140 table = [] for i in range(256): if i < threshold: table.append(0) else: table.append(1) out = img_gray.point(table, ‘1‘) # out.save(‘auth_b.jpg‘) ‘‘‘ 识别验证码中的文字 ‘‘‘ auth = pytesseract.image_to_string(out) print(auth)
标签:rac top logs table 视频 灰度 imp tor open
原文地址:http://www.cnblogs.com/gao-xiang/p/7194055.html