python 爬虫 pytesseract 验证码识别:识别拉勾网验证码

pytesseract

安装pip install pytesseract

如果下载之后没有PIL图片读取的库,需要下载 pip install PIL 或者pip install Pillow

代码

from urllib import request
from time import sleep

import pytesseract
from PIL import Image


def main():
    pytesseract.pytesseract.tesseract_cmd = r'D:\Tesseract-OCR\tesseract.exe'
    url = 'https://passport.lagou.com/vcode/create?from=register&refresh=4'
    while True:
        request.urlretrieve(url, 'y.jpg')
        image = Image.open('y.jpg')
        text = pytesseract.image_to_string(image)
        print(text)
        sleep(3)


if __name__ == '__main__':
    main()

 

猜你喜欢

转载自blog.csdn.net/qq_27648991/article/details/81461588