tesseract识别验证码

 安装pytesseract库

import time

import pytesseract
from urllib import request
from PIL import Image


def main():
    url = "https://passport.lagou.com/vcode/create?from=register$refresh=1513082291955"
    while True:
        request.urlretrieve(url, 'captcha.png')
        image = Image.open('captcha.png')
        text = pytesseract.image_to_string(image, lang="tessdata/eng")
        print(text)
        time.sleep(2)


if __name__ == '__main__':
    main()

 

你可能感兴趣的:(python,爬虫)