7_2 tesseract处理验证码
一、简单验证码识别处理
1 """""" 2 3 4 import pytesseract 5 from PIL import Image 6 from urllib import request 7 import time 8 9 def main(): 10 # 这个url也可以通过登录页面分析获取,也可以直接从network复制过来 11 url = "https://cas.sru.edu.cn/lyuapServer/captcha.jsp?time0.12309574802401424" 12 while True: 13 request.urlretrieve(url, 'capt.png') 14 image = Image.open('capt.png') 15 text = pytesseract.image_to_string(image) 16 print(text) 17 time.sleep(3) 18 19 if __name__ == '__main__': 20 main()